Home
Gaurav's GitHub Page
Cancel

Find all pairs with a given sum (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given two unsorted arrays A of size N and B of size M of distinct elements, the task is to find all pairs from both arrays whose sum is equal to X. Note: All pairs should be p...

Longest Common Prefix in an Array (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given an array of N strings, find the longest common prefix among all strings present in the array. Return “-1” if there is no common prefix. geeksforgeeks SOLUTION class So...

Equilibrium Point (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given an array A of n non negative numbers. The task is to find the first equilibrium point in an array. Equilibrium point in an array is an index (or position) such that the s...

Leaders in an array (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given an array A of positive integers. Your task is to find the leaders in the array. An element of array is a leader if it is greater than or equal to all the elements to its ...

Missing number in array (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given an array of size N-1 such that it only contains distinct integers in the range of 1 to N. Find the missing element. geeksforgeeks SOLUTION class Solution { int mi...

Array Subset of another array (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given two arrays: a1[0..n-1] of size n and a2[0..m-1] of size m, where both arrays may contain duplicate elements. The task is to determine whether array a2 is a subset of arra...

Sort an array of 0s, 1s and 2s

PROBLEM DESCRIPTION Given an array of size N containing only 0s, 1s, and 2s; sort the array in ascending order. geeksforgeeks SOLUTION This is a very interesting question and the optimal soluti...

Pascal's Triangle

PROBLEM DESCRIPTION Given an integer numRows, return the first numRows of Pascal’s triangle. In Pascal’s triangle, each number is the sum of the two numbers directly above it. leetcode SOLUTION ...

Max Consecutive Ones III

PROBLEM DESCRIPTION Given a binary array nums and an integer k, return the maximum number of consecutive 1’s in the array if you can flip at most k 0’s. SOLUTION class Solution { public int...

Validate Binary Search Tree

PROBLEM DESCRIPTION Given the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: The left subtree of a node contains only nodes...