We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Min Max Riddle
- Discussions
Min Max Riddle
Min Max Riddle
Sort by
recency
|
108 Discussions
|
Please Login in order to post a comment
in swift
Python solution with a stack. You need to split solution in 2 parts:
Go through the array and add to stack till the next number is smaller than the last value added to stack. When it happens you pop from the stack checking if value is higher than value in max windows array.
You end up with array with maximum windows for some window lengths. You have to populate the missing values with values from the right using a logic that window length for bigger window is also at least maximum for a smaller window.
`
JS code template has naming issues, HackerRank have to check the description and the code
Get left limit and right limit of every number in the array. This will give temporary min-max for every window size. Calculate the index as per the formula index = right - left.
Post this store the max of A[i] and res[index] into result[index]. Then, run a backward scan on result array to find min-max of left over window sizes.
Important Note: Min-max of a window size N will always be less than or equal to the window size of N-1.
can anyone help me with this code I can pass the 1st three cases but for the other cases getting wrong output.