Given Q queries each with inputs L and R, find all composite numbers in the inclusive range [L, R].
Find common elements in three sorted arrays.
Explain AVL trees and their operations
Print all permutations of a given string.
General data structures and algorithms questions
Write the algorithm for Floyd-Warshall algorithm
Convert a prefix expression to postfix using a stack
Solve and explain a coding problem related to strings.
Find the longest palindromic substring in a given string.
Explain how Hash Maps work and how collisions are handled.
Write an algorithm for a problem using Dynamic Programming
Find the maximum size subarray with equal number of 0s and 1s.
Explain or write an algorithm for path finding using BFS or DFS
Write the algorithm or logic for a given problem in your own words.
Explain the algorithm or pseudocode to solve a problem using backtracking.
Explain and analyze sorting algorithms, including their time and space complexities
Implement the Floyd-Warshall algorithm to find all-pairs shortest paths in a graph.
Given a number N, return the Kth nearest prime number based on absolute difference from N.
Write an algorithm to solve a real-life problem using standard computer science algorithms
Given an array and a target sum, find the pair of elements whose sum is closest to the target.
Form the largest even number possible using at most one swap operation on the digits of a given number.
An array consists of 0s and 1s. Find the length of the longest subarray containing equal number of 0s and 1s.
Find the area of the largest triangle that can be formed inside a rectangle and round it to the nearest integer
Given a 2D n x n matrix, print the sum of those diagonal elements whose count is greater than 3 in the entire matrix
Explain Greedy Algorithms and Dynamic Programming. What is Quick Sort and Merge Sort? Compare their efficiency and use cases.
Given an integer array of size N, print all even numbers in non-decreasing order first, followed by all odd numbers in ascending order.
Given an array and an integer K, partition the array into K subarrays such that the maximum subarray sum is minimized. Return this minimum possible value.
How would you find the second largest element in an unsorted array? How would you find the nth largest element? What is the time complexity in both cases?
Given two strings, sort the first string based on the order of character occurrences in the second string. Characters absent in the second string should appear at the end in their original relative order.
Given a matrix, convert it into a square matrix by appending 1s where required, then compute the sum of diagonal elements such that a diagonal element is counted only if it appears an odd number of times outside the diagonal.
Given N villages arranged in a circular pattern with distances between consecutive villages and an energy drink at each village, determine the starting village index such that a traveler starting with zero energy can complete the full circle.
Alice and Bob are given some number of chocolates. When Alice has more chocolates, she leaves chocolates in the box equal to the number Bob has, and vice versa. This continues until both have equal chocolates or one has zero. Find the number of times chocolates are left in the box.
Write an algorithm to find the maximum sum submatrix in a 2D array.
Given an elevation map, compute how much water it can trap after raining.