Microsoft | Onsite | Group by buckets
Anonymous User
406
  1. Given a large sorted array of keys (Strings);
    distributes these keys, sorted, across approx 1000 buckets, so that each bucket has about the same number of characters;
    the requested output is an array of approx 1000 keys that represent, for each bucket, the highest key.

public List<String> groupByBuckets(List<String> keys) {}

public interface FixedReader {
 // Reads up to the next 4096 bytes of data from a file and stores 
 // the results in |buffer| at |offset| specified. 
 // Returns the number of bytes read into |buffer|. If the return
 // value is less than 4096, this indicates that the end of file has
 // been reached.
 public int read4K(byte[] buffer);
}

public class ByteReader {
 public ByteReader(FixedReader fixedReader) {
 }


 // Read |byteCount| bytes from the stream passed into the
 // constructor, and store the data in |buffer|. |buffer| 
 // must be allocated by the caller and be at least
 // |byteCount| bytes long. The return value is the number of
 // bytes read and stored in |buffer|, and is always
 // <= |byteCount|. If the return value is < |byteCount|, it
 // indicates that the end of the file has been reached.
public int readBytes(byte[] buffer, int byteCount) {}
Comments (1)