i got the same passing percentages 100,10.22% with the brute force/O(n square) solution....this happens a lot with me,i get very randomized passing percentages at times and that leads me to doubt myself everytime or think im doing bad even if its a 100%(true in this case)....can someone explain me how it works...i rerun it at times and it changes from 100 to 50!?like is based on my internet speed or smth...i hv no clue anymore plzzz help me understand
The percentile score is unreliable and misleading. For example, the test cases were run on a very small range of data set, so even O(N sqrd) algorithms didn't take time to run on their servers. rely on the time/space complexity to analyse your result. I guess the percentile matters the most during contests.
A more simpler solution: Initialize two pointer left and right. right points to last element left points to second last element. Copy the last element to result arr. Initialize min variable to 0. The repeat: If left < right: result[left] = arr[left] - min if right < left: result[left] = arr[left] - arr[right] min = right left = left - 1 right = right - 1
I believe at 3:17 the last 9 can't have any discount... for that matter any last price can't have a discount, So the last price remains as it is.
Thsts right, silly mistake on my part
So, today I learned what a monotonic stack is.
Mee too dude.I was so close to solving it by myself, just couldn't actually do it
I just noticed that the color of your shirt in the thumbnail changes based on the difficulty
Nice. He doesn't have a yellow shirt tho lol
Crazy I just gave this problem a shot and you come out with the answer lmaoo
thanks boss, nice thumbnail pic as always 😁😂😂😂
first here bro, just started uploading leet code vids on spanish
Lol. I thought you were upselling discount on your neetcode website 😅
i got the same passing percentages 100,10.22% with the brute force/O(n square) solution....this happens a lot with me,i get very randomized passing percentages at times and that leads me to doubt myself everytime or think im doing bad even if its a 100%(true in this case)....can someone explain me how it works...i rerun it at times and it changes from 100 to 50!?like is based on my internet speed or smth...i hv no clue anymore
plzzz help me understand
The percentile score is unreliable and misleading. For example, the test cases were run on a very small range of data set, so even O(N sqrd) algorithms didn't take time to run on their servers.
rely on the time/space complexity to analyse your result. I guess the percentile matters the most during contests.
A more simpler solution:
Initialize two pointer left and right.
right points to last element
left points to second last element.
Copy the last element to result arr.
Initialize min variable to 0.
The repeat:
If left < right:
result[left] = arr[left] - min
if right < left:
result[left] = arr[left] - arr[right]
min = right
left = left - 1
right = right - 1