PROBLEM DESCRIPTION Suppose there is a circle. There are N petrol pumps on that circle. You will be given two sets of data. The amount of petrol that every petrol pump has. Distance from tha...
Circle of strings (geeksforgeeks - SDE Sheet)
PROBLEM DESCRIPTION Given an array arr of lowercase strings, determine if the strings can be chained together to form a circle. A string X can be chained together with another string Y if the last...
LRU Cache (geeksforgeeks - SDE Sheet)
PROBLEM DESCRIPTION Design a data structure that works like a LRU Cache. Here cap denotes the capacity of the cache and Q denotes the number of queries. Query can be of two types: SET x y: set...
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...