Next Greater Frequency ElementGiven an array, for each element find the value of the nearest element to the right which is having a frequency greater than that of the current element. If there does not exist an answer for a position, then make the value '-1'.Examples: Input: arr[] = [2, 1, 1, 3, 2, 1]Output: [1, -1, -1, 2, 1, -1
9 min read
Sort a stack using a temporary stackGiven a stack of integers, sort it in ascending order using another temporary stack.Examples: Input: [34, 3, 31, 98, 92, 23]Output: [3, 23, 31, 34, 92, 98]Explanation: After Sorting the given array it would be look like as [3, 23, 31, 34, 92, 98]Input: [3, 5, 1, 4, 2, 8]Output: [1, 2, 3, 4, 5, 8] Ap
6 min read
Delete middle element of a stackGiven a stack with push(), pop(), and empty() operations, The task is to delete the middle element of it without using any additional data structure.Input: s = [10, 20, 30, 40, 50]Output: [50, 40, 20, 10]Explanation: The bottom-most element will be 10 and the top-most element will be 50. Middle elem
8 min read
Maximum of minimums of every window size in a given arrayGiven an integer array arr[] of size n, the task is to find the maximum of the minimums for every window size in the given array, where the window size ranges from 1 to n.Example:Input: arr[] = [10, 20, 30]Output: [30, 20, 10]Explanation: First element in output indicates maximum of minimums of all
14 min read