2016.07/28 hedviginc phone interview



  • Input: Multiple arrays of sorted integers
    Output: Single array of sorted integers
    K Arrays, N integers / array

    Time complexity: KNlog(K)
    log(K)
    KNlog(K)

    KN

    Q2
    Input: Array of sorted integers, such that each number is in range (0, 2^31 -1), i.e. 4-byte integers
    Output: byte[] all the integers
    N = Number of input integers
    N > 1000

    Input: 1 10 20 40
    Output: <byte[]> / encodedArray

    decode(encodedArray, 0) = 1
    decode(encodedArray, 1) = 10
    decode(encodedArray, 2) = 20

    Integer to byte[]
    1 -> 000<1>
    01 -> 000<10>
    256 -> 00<1>0

    1 : byte -> 0001
    10 : byte -> 000<10>
    40 : byte -> 000<40>
    256: byte -> 00<00000001>0

    Input: 1 10 20 40

    byte[] encode(List inputArray)
    {
    byte[] b = new byte[44 * * inputArray.size()];
    for(int val : inputArray) {
    }

    System.out.println(b.length);

    }

    Integer decode(byte[] encodedArray, int index)
    {
    return convertToInt(encodedArray[4*index]);
    }

    int convertToInt(byte[] input)
    {
    }


登录后回复
 

与 BitTiger Community 的连接断开,我们正在尝试重连,请耐心等待