ProDeveloperTutorialonDecember 26, 2024 Given a linked list, check if it is a palindrome or not. Solution in C++ Solution to this problem can be found in 3 steps: 1. First find the middle of the linked list 2. Reverse the linked list from the middle 3.…
ProDeveloperTutorialonDecember 26, 2024 C++ program to implement queue using stacks. So our queue will be having following below functions: my_push(n) This function should insert the element “n” at the end of the queue my_pop()…
ProDeveloperTutorialonDecember 26, 2024 You are given a string that contain a basic expression, calculate the result. Solution in C++. Example: “ 1 + 3” = 4 Multiplication and division signs are not allowed. Only positive and negative numbers are allowed. This problem can be…
ProDeveloperTutorialonDecember 26, 2024 Given a 2d matrix, filled with 1 and 0. Find the maximum sub-matrix that has only 1’s and return the area. Given matrix: Maximum sub-matrix: To solve this problem, we shall use Dynamic Programming. For the given M * N matrix, we shall take another M…
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…