prodigy
BAN USER
Comments (10)
Reputation 15
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
-1
of 1 vote
Min-heap with insertion time as "time_t", where one periodically peeks heap to find oldest element and remove if its older than 60 secs (current_time - time_t).
Insert new element.
Keep a sum var which adds every new element inserted and subtracts value of removed node.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
Window Sliding problem.
- prodigy January 20, 20161. Slide windows of size 3 and find multiplication of n-1*n*n+1.
2. Keep max variable for max multiplication and ptr to n.
3. keep a DP[] array to store individual multiplication.
4. Remove n and use max val. Also update n+1 to n and dp[n+1] only. Find max. MaxHeap can be used but will need to create object to keep relationships.
5. o(n^2) to find max n times => can be reduced to o(nlogn) using heap or sorting.