Write a program to Implement a queue using the stack. The implemented queue should support standard operations like enqueue, dequeue, and front. This is an excellent problem to learn problem-solving and visualize the use case of stack and queue operations.
Given an array X of n integers, write a program to find an array product such that product[i] is equal to the product of all the elements of X except X[i]. We need to solve this problem without using division operations. This is an excellent problem to learn problem-solving using prefix array and a single loop.
Given an array X of n elements filled with several integers, some of them being zeroes, write a program to move all the zeroes to the end. This is an excellent coding problem to learn space and time complexity optimization.
Given an array of n integers and a target number, write a program to check whether a pair sum exits in the array or not. In other words, we need to check whether pair of elements in the array sum exactly to the target value.
Write a program to remove the duplicates from the sorted array. For this we are given a sorted array, the task is to remove the duplicate elements such that there is a single occurrence of each element in the array.
Given two integer arrays, X and Y of size m and n. Write a program to find the intersection of these two arrays. The intersection of two arrays is a list of distinct elements present in both arrays. The elements in the intersection can be in any order. Suppose m > n and elements in both arrays are distinct.
Given an array A of integers, find out the maximum difference between any two elements such that the larger element appears after the smaller element. In other words, we need to find max(A[j] - A[i]), where A[j] > A[i] and j > i. This is an excellent problem to learn problem-solving using divide and conquer, transform and conquer and a single loop.
Given an array X of size n, we need to find the maximum and minimum element present in the array. This coding problem has been asked during facebook and microsoft interview.
Given an array X consisting of 0s, 1s, and 2s. Write a program to sort the array of 0’s, 1’s, and 2’s in ascending order. This is a famous coding interview problem asked in facebook, microsoft and amazon.
A sorted and rotated array of size n is given, write a program to find the minimum element in the array. Rotation by k times means that the first k sorted elements of the array will move to the last k positions, and the last n - k sorted elements move to the first n - k positions (in an anti-clockwise fashion).
Given an array of n non-negative integers height[n], where each represents a point at coordinate (i, height[i]). n vertical lines are drawn such that the two endpoints of line i is at (i, height[i]) and (i, 0). Write a program to find two lines, which together with the x-axis form a container, such that the container contains the most water.
Given an array X of distinct elements, write a program to find all the unique triplets in the array whose sum is equal to zero. For example, suppose such triplets in the array are X[i], X[j] and X[k] then X[i] + X[j] + X[k] = 0. Note : solution set must not contain duplicate triplets.
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. The path has to end on a leaf node.
Given an array X of size n, write a program to find the most frequent element in the array, i.e. the element which occurs the most number of times. It is assumed that at least one element is repeated.
Subscribe to get weekly content on data structure and algorithms, machine learning, system design and oops.