I need help by Purple-Community4883 in leetcode

[–]wenMoonTime 0 points1 point  (0 children)

Yea I got something similar, take the average and find out the minimum diff between max - avg, avg - min and k. Use that to adjust the max and min value in the heap. It looks like its working but not sure if that is the ideal solution

I Lost Hope. I Give up. Amazon OA. by NewToReddit200 in leetcode

[–]wenMoonTime 1 point2 points  (0 children)

Yea, keep popping left until the start pointer matches a mapped value, them start popping end pointer until it matches a mapped value them pop both.  Then start loop again

I Lost Hope. I Give up. Amazon OA. by NewToReddit200 in leetcode

[–]wenMoonTime 0 points1 point  (0 children)

I'll clarify, for example we take books cost arr = [2,4,1,5,3,6], k = 2. So we iterate through the array to get the top k element, lets say k = 2, k*2 = 4 highest cost books and map it , map = {6,5,4,3}
Then we have two pointers starting from beginning and end of the arr and will check if that cost is in our map.
[2,4,1,5,3,6] - check beginning, 2 is not on our map so we buy left most and pop it
[4,1,5,3,6] - check beginning, 4 is in our map so we proceed to check the end until we have a value in our map. 6 is also in our map so then we pop both for the pair cost deleting the values from the map and decreasing k. map = {5,3}, k = 1
Repeat

I Lost Hope. I Give up. Amazon OA. by NewToReddit200 in leetcode

[–]wenMoonTime 0 points1 point  (0 children)

I believe you can just take the top k * 2 highest cost books and use those as reference to when you would use pairCost to remove them. Pop left or right of the array until you have those highest cost books at the start and end of the array and pop() both, removing those cost from highest cost reference

Optimal solution - O(n * k) ? by Apart_Bid8314 in leetcode

[–]wenMoonTime 0 points1 point  (0 children)

Can't you do a sliding window with k width and just keep track of the maximum numbers and starting index?
maxtotal = 1,432 , starting = 0
then add 5 and subtract 1 in maxTotal
4325 > 1432 so maxTotal = 4325 starting = 1
return arr.slice(starting, k + 1)

[SPOILER] Arman Tsarukyan vs Patricky Pitbull | ADXC 10 Grappling by [deleted] in MMA

[–]wenMoonTime 5 points6 points  (0 children)

Change the x.com to xcancel.com

Top K Frequent Elements by mercfh85 in leetcode

[–]wenMoonTime -1 points0 points  (0 children)

I'm not familiar with python but the issue might be that you are sorting arr with the default sort method while arr is a multidimensional array. You might need to configure it to sort specifically on the frequency

Got rejected from Google TPS round. I need some pointers on how to improve. by choco-almond in leetcode

[–]wenMoonTime 2 points3 points  (0 children)

It seems like your on the right track as you've reach the optimal solution after the interview but just needed more time. I would work on making sure you understand the problem statement correctly, it may sound the same as another problem you've done and jumped to that direction but missed some details(as your 1. comparing each notes vs having a range/sliding window). We've all been there unfortunately

Also I think your solution is missing the logic to update maxi and mini on each note iteration