Empresa engajada
1st phonescreen: 1) background 2) algorithmic question which i dont remember but it was average difficulty level 3) Pagination in java - Given an implemented method getFeed(userId, StartTimeStamp, EndTimeTimeStamp) which returns a List<Feed>, right an API to return feeds to a mobile client. Design the API from scratch
Sigiloso
He is right. Below is some rough implementation. To clarify your doubts: 1.) He wants your to use some sort of cache so that calls to getFeed() can be minimized. May be its an RPC call over network. Using cache while doing pagination will help because then we can cache the results of the getFeed(). 2.) He wants backend to `remember` range returned List getPaginatedFeed(String userId, int maxLimit, long startTimeStamp) { List list; if (cache.contains(userId)) { list = cache.get(userId); } else { list = getFeed(userId, startTimeStamp, System.currenttimemillis()); cache(userId, list); countCache.put(userId, 0); } int count = countCache.get(userId); if (list.size() newList = new ArrayList(); for (; count getFeed(String userId, long startTimeStamp, long endTimeTimeStamp) { }