ProDeveloperTutorialonDecember 26, 2024 You are given an unsorted array, and a key number, find the largest number of that key position. array = { 3, 7, 6, 5, 2, 9, 4} key = 3 Solution = 6. Question explanation: First sort the above array: {2, 3, 4, 5, 6, 7, 9} So the keyth…
ProDeveloperTutorialonDecember 26, 2024 Given the heights of histogram using an array, you need to find the largest area rectangle in that histogram. Solution in C++ Question explanation: A histogram is a bar graph, where each unit is 1. You are given an array representing the height of the histogram. You…
ProDeveloperTutorialonDecember 26, 2024 Given an array and a key element, find the number of continuous elements whose sum is greater than the key element. Example: array = {1, 2, 3, 4, 5, 6, 7, 8, 9}; k = 30 Output: 4 This is because the sub array [6, 7, 8, 9] This problem can be solved with “two…
ProDeveloperTutorialonDecember 26, 2024 Given 2 strings, check if they are isomorphic strings. 2 strings are said to be isomorphic, if one letter in the first string can be replaced by another letter in the second string. Example 1:…
ProDeveloperTutorialonDecember 26, 2024 Given an array, find the majority element, solution in C++ A majority element, is an element that is repeated more than half of the times. Example: [1, 2, 3, 4, 4, 4, 4, 4, 5] Output: 4. Total number…
ProDeveloperTutorialonDecember 26, 2024 Find the minimum element from an array that is sorted and is rotated, solution in C++ Example 1: Input: [3,4,5,6,7,1,2] Output: 1 We shall use 2 pointers to solve this problem. Below are steps how the solution works: 1. Frist we…
ProDeveloperTutorialonDecember 26, 2024 Given an integer array, find the maximum product made from continuous elements in that array. Solution in C++ Example 1: Input: [2,3,-1,3] Output: 6 Explanation: [2,3] are continuous and has the largest product 6. The steps of the working of the…
ProDeveloperTutorialonDecember 26, 2024 You are given a sentence, reverse the string word by word Example: Input: “prodevelopertutorial is a good website”, Output: ” website good a is prodevelopertutorial”. The…
ProDeveloperTutorialonDecember 26, 2024 Given an expression in reverse polish notation, evaluate it and get the output in C++ In reverse polish notation, operands will be first followed by operators. For example, 2 – 3 in reverse polish notation will be 2 3 – 4 + 5…
ProDeveloperTutorialonDecember 26, 2024 Given an unsorted linked list, sort the list using merge sort. Example: 3 -> 4 -> 5-> 1 -> 2 Output: 1 -> 2 -> 3 -> 4 -> 5 Merge sort is a divide and conquer algorithm. Here we…