Interview Preparation Kit
Arrays
Name | Preview | Code | Difficulty |
---|---|---|---|
2D Array - DS | How to access and use 2d-arrays. | Python | Easy |
Array Manipulation | Perform m operations on an array and print the maximum of the values. | Python | Hard |
Arrays: Left Rotation | Given an array and a number, d, perform d left rotations on the array. | Python | Easy |
Minimum Swaps 2 | Return the minimum number of swaps to sort the given array. | Python | Medium |
New Year Chaos | Determine how many bribes took place to get a queue into its current state. | Python | Medium |
Dictionaries and Hashmaps
Name | Preview | Code | Difficulty |
---|---|---|---|
Hash Tables: Ransom Note | Given two sets of dictionaries, tell if one of them is a subset of the other. | C++ | Easy |
Sherlock and Anagrams | Find the number of unordered anagramic pairs of substrings of a string. | Python | Medium |
Two Strings | Given two strings, you find a common substring of non-zero length. | Python | Easy |
Sorting
Name | Preview | Code | Difficulty |
---|---|---|---|
Sorting: Bubble Sort | Find the minimum number of conditional checks taking place in Bubble Sort | Python | Easy |
Sorting: Comparator | Write a Comparator for sorting elements in an array. | C++ | Medium |
Merge Sort: Counting Inversions | How many shifts will it take to Merge Sort an array? | Python | Hard |
String Manipulation
Name | Preview | Code | Difficulty |
---|---|---|---|
Alternating Characters | Calculate the minimum number of deletions required to convert a string into a string in which consecutive characters are different. | Python | Easy |
Common Child | Given two strings a and b of equal length, what’s the longest string (s) that can be constructed such that s is a child to both a and b? | C++ Python | Medium |
Strings: Making Anagrams | How many characters should one delete to make two given strings anagrams of each other? | Python | Easy |
Sherlock and the Valid String | Remove some characters from the string such that the new string’s characters have the same frequency. | Python | Medium |
Greedy Algorithms
Name | Preview | Code | Difficulty |
---|---|---|---|
Minimum Absolute Difference in an Array | Given a list of integers, calculate their differences and find the difference with the smallest absolute value. | Python | Easy |
Search
Name | Preview | Code | Difficulty |
---|---|---|---|
Hash Tables: Ice Cream Parlor | Help Sunny and Johnny spend all their money during each trip to the Ice Cream Parlor. | Python | Medium |
Pairs | Given N numbers, count the total pairs of numbers that have a difference of K. | Python | Medium |
Stacks and Queues
Name | Preview | Code | Difficulty |
---|---|---|---|
Balanced Brackets | Given a string containing three types of brackets, determine if it is balanced. | Python | Medium |
Queues: A Tale of Two Stacks | Create a queue data structure using two stacks. | C++ | Medium |
Largest Rectangle | Given n buildings, find the largest rectangular area possible by joining consecutive K buildings. | Python | Medium |
Graphs
Name | Preview | Code | Difficulty |
---|---|---|---|
BFS: Shortest Reach in a Graph | Implement a Breadth First Search (BFS). | C++ | Hard |
DFS: Connected Cell in a Grid | Find the largest connected region in a 2D Matrix. | C++ | Hard |
Trees
Name | Preview | Code | Difficulty |
---|---|---|---|
Binary Search Tree : Lowest Common Ancestor | Given two nodes of a binary search tree, find the lowest common ancestor of these two nodes. | C++ | Easy |
Trees: Is This a Binary Search Tree? | Given the root of a binary tree, determine if it’s a binary search tree. | Python | Medium |
Tree: Height of a Binary Tree | Given a binary tree, print its height. | C++ Python | Easy |
Tree: Huffman Decoding | Given a Huffman tree and an encoded binary string, you have to print the original string. | C++ | Medium |
Linked Lists
Name | Preview | Code | Difficulty |
---|---|---|---|
Linked Lists: Detect a Cycle | Given a pointer to the head of a linked list, determine whether the list has a cycle. | C++ | Easy |
Find Merge Point of Two Lists | Given two linked lists, find the node where they merge into one. | C++ | Easy |
Insert a node at a specific position in a linked list | Insert a node at a specific position in a linked list. | C++ | Easy |
Inserting a Node Into a Sorted Doubly Linked List | Create a node with a given value and insert it into a sorted doubly-linked list | C++ | Easy |
Reverse a doubly linked list | Given the head node of a doubly linked list, reverse it. | Python | Easy |
Recursion and Backtracking
Name | Preview | Code | Difficulty |
---|---|---|---|
Recursion: Fibonacci Numbers | Compute the $n^{th}$ Fibonacci number. | C++ | Easy |
Recursion: Davis’ Staircase | Find the number of ways to get from the bottom of a staircase to the top if you can jump 1, 2, or 3 stairs at a time. | C++ | Medium |
Miscellaneous
Name | Preview | Code | Difficulty |
---|---|---|---|
Time Complexity: Primality | Determine whether or not a number is prime in optimal time. | C++ | Medium |
Flipping bits | Flip bits in its binary representation. | C++ | Easy |
Friend Circle Queries | Process the queries and after each query print the number of people largest friend circle. | Python | Medium |
Maximum Xor | Find the maximum xor value in the array. | C++ | Medium |