Posts
Gaurav's GitHub Page
Cancel

Search Pattern (Rabin-Karp Algorithm) (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given two strings, one is a text string and the other is a pattern string. The task is to print the starting indexes of all the occurrences of the pattern string in the text st...

Count total set bits (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION You are given a number n. Find the total count of set bits for all numbers from 1 to n (both inclusive). geeksforgeeks SOLUTION BRUTE-FORCE (TLE) class Solution{ //Fun...

Rotate Bits (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given an integer N and an integer D, rotate the binary representation of the integer N by D digits to the left as well as right and return the results in their decimal represen...

Rotate matrix elements clockwise (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given two integers M, N, and a 2D matrix Mat of dimensions MxN, clockwise rotate the elements in it. geeksforgeeks SOLUTION We handle the matrix layer by layer, starting ...

Alien Dictionary (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given a sorted dictionary of an alien language having N words and k starting alphabets of standard dictionary. Find the order of characters in the alien language. Note: Many or...

Heap Sort (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given an array of size N. The task is to sort the array elements by completing functions heapify() and buildHeap() which are used to implement Heap Sort. geeksforgeeks SOLUTI...

Palindrome Pairs (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given an array of strings arr[] of size N, find if there exists 2 strings arr[i] and arr[j] such that arr[i]+arr[j] is a palindrome i.e the concatenation of string arr[i] and a...

Common Elements (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given two lists V1 and V2 of sizes n and m respectively. Return the list of elements common to both the lists and return the list in sorted order. Duplicates may be there in th...

Minimum XOR value pair (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Given an array of integers of size N find minimum xor of any 2 elements. geeksforgeeks SOLUTION APPROACH 1 The idea is to sort the array and then find the xor of all the nu...

Trie | (Delete) (geeksforgeeks - SDE Sheet)

PROBLEM DESCRIPTION Trie is an efficient information retrieval data structure. This data structure is used to store Strings and search strings, String stored can also be deleted. Given a Trie root...