abhinav
BAN USER- 0of 0 votes
AnswersFill in the following methods:
- abhinav in United Statespublic interface PointsOnAPlane { /** * Stores a given point in an internal data structure */ void addPoint(Point point); /** * For given 'center' point returns a subset of 'm' stored points that are * closer to the center than others. * * E.g. Stored: (0, 1) (0, 2) (0, 3) (0, 4) (0, 5) * * findNearest(new Point(0, 0), 3) -> (0, 1), (0, 2), (0, 3) */ Collection<Point> findNearest(Point center, int m); }
| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Algorithm
- 1 Answer Improving basics
Hey folks
- abhinav March 04, 2013
I was interviewed yesterday for a programming/web-development profile.
I cleared 3 rounds but was rejected in the last round(the programming round).
The question I was asked was a basic one:implement get_max function in a stack. Though I did it,the time complexity was not good,O(n). I understood how to do it later but I wanted to know how I can improve upon my basics.
I have solved a lot of problems on Codechef/SPOJ but never encountered such a problem where my basics were questioned(Correct me if I'm wrong).
Codechef/SPOJ was more of implementing the STL libraries/puzzle solving/number theory. I hardly remember when I last implemented a stack/queue/priority queue/tree from scratch without using libraries.
How do I get my basics in place??
I would appreciate frank opinions and also resources/ opinions where people faced the same problem and how they tackled it.
Thanks a lot| Flag | PURGE
Suppose i have petrol array = 2 7 9 3 and dist array = 1 6 12 3
Then according to your code it should give ans as 3 but if we proceed from 3 it would be impossible to reach 3 back again as after travelling 3: sum=0; then it should move back to
petrol station 0 so sum=1 then sum=2 then sum=-1
This is similar to merge function of mergesort where we copy data into a new array while traversing both arrays. It is mentioned in the question not to copy data but to only manipulate the pointers.
- abhinav March 09, 2014