- Q1: Print all anagrams of a given string
- Q2: Print matrix in spiral order
- Q3: Delete n digits from a number such that the result is the minimum number
- Q4: Combine two sorted singly linked lists
- Q5: 9 Marbles and weighing machine
- Q6: 3 buckets and apples and oranges
- Q7: Max of two numbers without using any branching, if-else, loop and conditional operators
- Q8: Finding equillibrium index
- Q9: Frog trying to cross river over falling leaves (no solution to this question)
- Q10: Given two keys K1 and K2, print all the values in the range K1 and K2 from a given BST
- Q11: Celebrity problem

- Q1: Root to leaf path equal to a given number n.
- Q2: Print all pairs of anagrams in a given array of strings.
- Q3: Level order traversal of a tree.
- Q4: Given an array of words, print all anagrams together.
- Q5: Convert a given tree into a sum tree.
- Q6: Delete middle element of a linked list.
- Q7: Convert a binary tree into a circular double linked list.
- Q8: Print nodes at K distances from the root.
- Q9: Even occuring elements in an array of limited range.
- Q10: Print first n numbers with exactly two bits set.
- Q11: Find the element in an array that appears once.

- Q1: Find the maximum repeating number in O(n) and O(1) extra space.
- Q2: Anagram substring search (or search for all permutatins)
- Q3: Remove all duplicates from a given string.
- Q4: Flattening a linked list.
- Q5: Rearrange a given list so that it consists of alternating min-max elements.
- Q6: Design a tiny URL or URL shortener.
- Q7: Convert a given number to words.
- Q8: Longest even length substring such that sum of the first and second half is the same
- Q9: Find the excel column name from a given column number.

- Q1: Rotate square matrix in-place by 90 degrees.
- Q2: Array rotation (5 methods)
- Q3: Snake and Ladder problem: minimum number of throws required to reach the last cell.
- Q4: Finding the number of islands.
- Q5: Stepping numbers (2 methods)
- Q6: Print all possible words from phone digits.
- Q7: Square root of an integer.
- Q8: Find two missing numbers (3 methods)
- Q9: Find the missing number (2 methods)

- Q1: Boundary traversal of a binary tree.
- Q2: Lowest Common Ancestor (LCA) problem.
- Q3: Reverse level order traversal.
- Q4: Level order traversal in spiral form.
- Q5: Implement Queue using stacks.
- Q6: Intersection of two linked lists.
- Q7: Determine if two trees are identical.
- Q8: Detect cycle in a directed graph.
- Q9: Clone a linked list where each node has next and random pointer.
- Q10: Check if two nodes are on the same path in a tree.

- Q1: Sorted Linked List to Balanced BST
- Q2: Construct a binary tree from a given parent array representation.
- Q3: Height of a binary tree represented by parent array.
- Q4: The bedlam in the party (BFS solution)
- Q5: Connect the nodes at the same level in a tree.
- Q6: Merge two sorted linked lists.
- Q7: Delete the middle of the linked list.
- Q8: Find the intersection point of two linked lists.
- Q9: Reverse a linked list (recursive and non-recursive)
- Q10: Check whether circular linked list or not.
- Q11: Detect loop in a linked list.
- Q12: Detect and remove loop in a linked list.

- Q1: Check if a tree is balanced or not.
- Q2: Diameter of a binary tree.
- Q3: Delete a node in a linked list when the head of the list is not given.
- Q4: Maximum width of a tree.
- Q5: Convert to mirror tree.
- Q6: Program to check if a binary tree is BST or not.
- Q7: Sorted insert for circular linked list.
- Q8: Merge two sorted linked list in reverse order.
- Q9: Sort a linked-list of 0s, 1s and 2s.
- Q10: Pairwise swap elements of a given linked list by changing links.

- Q1: Reverse a linked list in groups of a given size.
- Q2: LRU implementation
- Q3: Calculate pow(x, n)
- Q4: Modular exponentiation
- Q5: Find the numbers from an array containing (2*n+2) positive numbers.
- Q6: Find subarray with a given sum.
- Q7: Reverse words in a given string.
- Q8: Find the minimum element in a sorted and rotated array.
- Q9: Find if two rectangles overlap.
- Q10: Check whether a given point lies inside or outside a polygon.

- Q1: Check if a number is a multiple of 3
- Q2: Find the position of the only set bit
- Q3: Design a website hit counter.
- Q4: Maximal subarray problem (Kadane's algorithm)
- Q5: Move all zeroes to the end of the array.
- Q6: Sum of absolute differences of all pairs in a given array.
- Q7: Find the next greater number with the same set of digits.
- Q8: Lexicographically next permutation.
- Q9: Search an element in a sorted and rotated array.
- Q10: Find the duplicates in O(n) time and O(1) extra space in an array containing elements from 0 to (n-1).

- Q1: Computational complexity of finding the nth Fibonacci number.
- Q2: Count the number of occurrences of an element x in a sorted array in O(log(n))
- Q3: Given a matrix of distinct values and a sum, find pairs with a given sum such that elements of the pair are in different rows.
- Q4: Trapping the rain water (given an elevation map)
- Q5: Left view of a binary tree.
- Q6: Find the kth smallest element in a BST.
- Q7: Count the number of ways to reach the nth stair.
- Q8: Find the plus (+) pattern of maximum size in a 2D array of 1s and 0s.
- Q9: Minimum cost path (dynamic programming solution)
- Q10: Check if two linked lists merge. If so, where.

- Q1: Chocolate distribution problem.
- Q2: Maximum size square sub-matrix of a given matrix (of 0s and 1s) with all 1s.
- Q3: Find row of the matrix (of 0s and 1s) with max number of 1s.
- Q4: Find max sum of leaf-to-root path in a binary tree.
- Q5: Given an array of positive and negative integers, re-arrange it so that you have positive integers on one end and negative integers on other. Order of the elements should be retained.
- Q6: Rearrange positive and negative numbers alternatively in O(n) time and O(1) extra space.
- Q7: Rearrange positive and negative numbers in O(n) time and O(1) extra space.
- Q8: Merge k sorted arrays.
- Q9: Construct Tree from given Inorder and Preorder traversals.
- Q10: Construct a binary tree from postorder and inorder traversals.
- Q11: Connecting n ropes with minimum cost.
- Q12: Find the longest palindromic substring. Desired time complexity is O(n^2) and space complexity is O(1).

- Q1: How to implement undo/redo functionality?
- Q2: How strtok() split strings into tokens in C?
- Q3: Given a list of array, returns a list of arrays, where each array is a combination of one element in each given array.
- Q4: Longest Increasing subsequence (DP solution).
- Q5: Combination sum: given a set of candidate numbers (C) and a target number (T), find all unique combinations in C, where the candidate nummbers sums to T.
- Q6: Lenght of the longest common subsequence.
- Q7: Print the longest common subsequence.
- Q8: Longest Palindromic subsequence.
- Q9: Find the k most frequenct words in a file.
- Q10: Power set.
- Q11: Relative sorting: sort an array according to the order defined by another array.
- Q12: Inversion count for a given array.

- Q1: Partition Function (Quicksort)
- Q2: Nuts and Bolts Problem (Lock & Key problem)
- Q3: Amend the sentence (put space between words, convert uppercase to lowercase)
- Q4: Orientation of 3 ordered points (clockwise, counterclockwise, collinear)
- Q5: Check if two line segments intersect (using orientation technique)
- Q6: Count all distinct pairs in an integer array with difference equal to k.
- Q7: Sort an array of 0s, 1s and 2s (Dutch National flag problem).
- Q8: Multiply large numbers as strings.
- Q9: Dijkstras's shortest path algorithm.
- Q10: Deleting a node in a BST.
- Q11: Construct BST from a preorder traversal.
- Q12: Serialize/Deserialize a binary tree.

- Q1: Remove duplicates from a sorted linked list.
- Q2: Remove duplicates from an unsorted linked list.
- Q3: Detect cycles in an undirected graph.
- Q4: Write a linked list class along with append function (add node to the end) and destructor function.
- Q5: Given two numbers in the form of a singly linked list in such a way that the most significant bit is at the end (e.g., 123 will be 1 -> 2 -> 3), write a function that takes arguments as pointers to the head of the lists and returns pointer to the head of another linked list which represents the added number.
- Q6: Add two numbers represented as lists (similar to the above question) such that the most significant bit is at the tail.
- Q7: Find the pairs with a given sum in a doubly linked list.
- Q8: Given a string, find its first non-repeating character.
- Q9: Trie data structure (insertion, search).
- Q10: k''th non-repeating character in a string.
- Q11: How to implement a search engine?
- Q12: Given a text file, find the positions that the word occurs in the file (you have to find positions of many words in the same file).

- Q1: Multiply two matrices (in O(n^3))
- Q2: Implement sizeof
- Q3: The 2 Egg puzzle.
- Q4: Find types and values of the expressions.
- Q5: Find error in code.
- Q6: Given a boolean matrix, modify it such that if m[i][j] is 1, then make all the i'th row and j'th column as 1.
- Q7: Given a set of time intervals, merge all overlapping intervals into one.
- Q8: Find the repeating and the missing number in the array.
- Q9: 3 ants on a triangle riddle.
- Q10: Pots of gold game (classic dynamic programming qn)
- Q11: Right view of a binary tree.
- Q12: Max product subarray: given an array containing both positive and negative numbers, find the product of the max product subarray. Expected time complexity O(n) and space complexity O(1).

- Q1: Maximum difference between 2 elements such that larger element appears after the smaller number.
- Q2: Stock Buy Sell to Maximize Profit – 1 (sell stock before you buy again)
- Q3: Stock Buy Sell to Maximize Profit – 2
- Q4: Product array except itself: given an array of integers, return output array such that output[i] is equal to the product of elements except input[i]. Solve it without division & in O(n).
- Q5: Union and intersection of two sorted arrays.
- Q6: Union and intersection of two unsorted arrays.
- Q7: Length of the longest substring without repeating characters.
- Q8: Arrange given numbers to form the biggest number.
- Q9: Minimum number of jumps to reach end (dynamic programming).
- Q10: Special Stack data structure which has get_min() operation. Requirement: push(), pop, top() and get_min() has to be executed in O(1) time complexity.
- Q11: Unique paths count (dynamic programming).
- Q12: Merge two sorted arrays: given two sorted arrays a1 and a2, merge a2 into a1 as one sorted array. Assume a1 has enough space to hold additional elements from a2.
- Q13: 3Sum (set 1) - find a triplet that sums to a given value (expected complexity: O(n^2))
- Q14: 3Sum (set 2) - all unique triples.
- Q15: 3Sum (set 3) - get the closest triplet that sums to a given target.

- Q1: Reverse Integer
- Q2: Find duplicate number: given an array containing n+1 integeres, where each integer is between 1 & n. Assume there is only one duplicate number, find it.
- Q3: Container with most water.
- Q4: Lexicographhical numbers: example: 13 should give [1, 10, 11, 12, 2, 3, 4, ..., 9]
- Q5: Kth largest element in an unsorted array.
- Q6: Symmetric tree: given a binary tree, check whether it's a mirror of itself (symmetric around center).
- Q7: Palindrome permutation: determine if a permutation of the string could form a palindrome.
- Q8: Factorial trailing zeroes: find number of trailing zeroes in n!.
- Q9: Palindrome partitioning: partition string such that every substring is a palindrome. Example: s = "aab", output: [["aa", "b"], ["a", "b", "b"]].
- Q10: Remove duplicates from a sorted array.
- Q11: Binary search tree iterator: next() and hasNext() functions.
- Q12: Find peak element (divide and conquer).
- Q13: Find local minima in an array (divide and conquer).
- Q14: Flatten a binary tree into a linked list.
- Q15: Water and Jug problem: given 2 jugs with capacities x and y, find if you can measure exactly z litres using them.
- Q16: Minimum number of arrows to burst balloons (greedy).
- Q17: Valid palindrome: given a string, determine if it's a palindrome.
- Q18: Rotate image by 90 degree clockwise.
- Q19: Add digits: find the digital root.
- Q20: Find bottom left tree value: given a binary tree, find the leftmost value in the last row of the tree.

- Q1: House Robber (dynamic programming)
- Q2: House Robber 2 (dynamic programming)
- Q3: Coin Change (dynamic programming)
- Q4: Paint Fence (dynamic programming)
- Q5: Russian Doll Envelopes
- Q6: Valid Parentheses
- Q7: Longest Common Prefix
- Q8: Word Search (DFS)
- Q9: Count and say.
- Q10: Meeting Rooms
- Q11: Median of two sorted arrays (divide & conquer)
- Q12: Valid perfect square
- Q13: Is subsequence
- Q14: Insert, Delete, GetRandom in O(1).
- Q15: Design Tiny URL
- Q16: Sliding Window Maximum
- Q17: Search a 2D Matrix II
- Q18: Search a 2D Matrix I
- Q19: Palindrome Linked list
- Q20: Hamming Distance (bit manipulation)

- Q1: Permutation Sequence
- Q2: Word Break (dynamic Programming)
- Q3: H-Index
- Q4: Fork & copy-on-write.
- Q5: How malloc() and free() work?
- Q6: Memory layout of C programs.
- Q7: Data Structure for Phone book/contacts.
- Q8: Read N characters given Read4() II - call mutiple times.
- Q9: Read N characters given Read4() - call once.
- Q10: Swap nodes in pairs.
- Q11: Missing number: given array containing n distinct numbers, find the one that is missing.
- Q12: First missing postive number.
- Q13: Intersection of two arrays.
- Q14: Power of 4: given a signed integer (32 bits), check whether if it's a power of 4.
- Q15: Game of life: write a function to compute the next state of the board given its current state.
- Q16: Majority element (Boyer-Moore algorithm)
- Q17: Majority element II - find all elements that appear more than n/3 times.
- Q18: Nim Game
- Q19: Ordered map implementation using BST & Hashtable.
- Q20: Singleton design pattern: restrict the instantiation of a class to one object.

- Q1: Sort strings by length.
- Q2: Print linked list in reverse order without reversing it.
- Q3: Given an array of n non-negative integers, find the frequency of a particular element in arbitrary range.
- Q4: Max depth of a binary tree.
- Q5: Contains duplicate I: given an array of integers, find if the array contains duplicates.
- Q6: Contains duplicate II: find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k.
- Q7: Repeated DNA sequences.
- Q8: Search for a range: given an array of sorted integers, find the starting and the ending position of a given value (with complexity O(log n))
- Q9: Find the leaves of a binary tree and repeatedly delete leaves until empty.
- Q10: Valid number: validate if a string is numeric.
- Q11: Insert interval: insert a new interval to a given set of intervals and merge if necessary.
- Q12: Minimum window substring: find the smallest window in a string containing all characters of another string.
- Q13: Minimum size subarray sum: find the minimum lenght of a contiguous subarray of which the sum >= s.
- Q14: Ternary expression parser.
- Q15: Max points on a line: given n points on a 2D plane, find the max number of points that lie on the same straight line.
- Q16: Find the largest value in each tree row.
- Q17: Lowest Common Ancestor of a BST.
- Q18: Lowest Common Ancestor of a binary tree.
- Q19: Increasing triplet subsequence: find a sorted subsequence of size 3 in linear time.
- Q20: Minimum moves to equal array elements: find the minimum number of moves required to make all array elements equal, where a move is incrementing n-1 elements by 1.

- Q1: Minimum number of moves to equal array elements II
- Q2: Shortest Word Distance
- Q3: Moving average from data stream
- Q4: Add strings
- Q5: Find difference
- Q6: Plus One
- Q7: Word Ladder
- Q8: Evaluate Reverse Polish Notation
- Q9: Factor Combinations
- Q10: Zig Zag Iterator
- Q11: Wiggle Sort
- Q12: Wiggle Sort 2
- Q13: Nested List Weighted Sum
- Q14: Nested List Weighted Sum 2
- Q15: Shortest Word Distance 2
- Q16: Shortest Word Distance 3
- Q17: Permutations 2 (may contain duplicate entries; find unique permutations)
- Q18: Add binary (as strings)
- Q19: Binary Tree Paths
- Q20: Binary Tree right side view.

- Q1: Binary Tree Inorder Traversal (iterative)
- Q2: Minimum depth of a binary tree.
- Q3: Binary Tree Level order Traversal 2: given a binary tree, return the bottom-up level order traversal of its nodes' values.
- Q4: Binary Tree Preorder traversal (iterative).
- Q5: Binary Tree Vertical Order Traversal (from top to bottom, column by column).
- Q6: Top K frequent elements: given a non-empty array of integers, return the k most frequent elements.
- Q7: Find the mode (most frequently occuring element) in a Binary Search Tree. (try a solution without extra space).
- Q8: Decode Ways: given an encoded message containing digits, determine the total number of ways to decode it (dynamic programming).
- Q9: Flip Game 1: Given a string that contains only '+' and '-' characters, you and your friend takes turn to flip two consecutive '++' into '--'. Write a function to compute all possible states of the string after one valid move.
- Q10: Flip Game 2: for the question above, the game ends when a person can no longer make a move and therefore the other person will be the winner. Write a function to determine if the starting player can guarentee a win.
- Q11: Differences between C++03, C++11 and C++14.
- Q12: Sum of perfect square numbers (tricky).
- Q13: Number of Islands (DFS).
- Q14: Inorder successor in BST.
- Q15: Path Sum 2: given a binary tree and a sum, find all root to leaf paths where each path's sum equals the given sum.
- Q16: Add and search word data structure design: desing a data structure that supports the following two operations: void addWord(word) and bool search(word). search(word) should be able to search a literal word or a regular expression containing a-z or a dot (.) character. The dot (.) character represents any one letter (application of Trie Data Structure).
- Q17: Boundary of a binary tree: given a binary tree, return the values of its boundary in anti-clockwise direction starting from the root.
- Q18: Two Sum 3 data structure design: Design and implement a TwoSum class. It should support the add and find operations. The add(int) adds a number to the interal data structure and find(int value) checks whether there exists a pair of numers whose sum is equal to the value.
- Q19: Binary Tree Postorder Traversal (iterative).
- Q20: Flatten Nested List iterator: given a nested list of integers, implement an iterator to flatten it. For example, if the list is [[1, 1], [2,[3, 4]], [1, 1]], the output should be [1, 1, 2, 3, 4, 1, 1].

- Q1: Flatted 2D Vector: implement an iterator to flatten a 2D vector.
- Q2: Construct binary tree from string (consisting of parenthesis and integers).
- Q3: Combination Sum 2: given a collection of candidate numbers (C) and target number (T), find all unique combinations in C where the candidate numbers sums to T.
- Q4: Target Sum: you are given a list of non-negative integers and a target sum S. Find how many ways to assign symbols '+' and '_' to make sum of integers equal to S.
- Q5: Closest Binary Search Tree value: find the value in the BST that is closest to the target.
- Q6: Count the complete tree nodes: given a complete binary tree, count the number of nodes.
- Q7: Integer Replacement: given a positive integer n and two operatios (if n is odd, replace n with either n+1 or n-1; and if n is even, replace n with n/2), find the minimum number of replacements needed for n to become 1.
- Q8: Power of 3: given an integer, write a function to determine if it is a power of 3.
- Q9: UTF-8 validation: given an array of integers representing the data, return whether it is a valid utf-8 encoding.
- Q10: Random Pick index: given an array of integers with possible duplicates, randomly output the index of a given target number (reservoir sampling).
- Q11: Linked list random node: given a singly linked list, return a random node's value from the list such that each node has the same probability of being chosen (reservoir sampling).
- Q12: Compute the max of two numbers without using any branching or looping operation.
- Q13: Max product of word lenghts: given a string of words, find the max value of length(word[i]) * length(word[j]) where the two words do not share common letters.
- Q14: Reverse bits (of a given 32 bit unsigned integer)
- Q15: Permutation in string: given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1 (rolling hash)
- Q16: Find all anagrams in a string: given a string s and a non-empty string p, find all the start indices of p's anagram in s (rolling hash).
- Q17: design Tic-Tac-Toe: can you do better than O(n^2) per move() operation?
- Q18: Course Schedule: given the total number of courses (n) and a list of pre-requisite pairs, is it possible for you to finish all courses? (topological sorting).
- Q19: Course Schedule 2: given the total number of courses (n) and a list of pre-requisite pairs, return the ordering of courses that you should take to finish all courses (topological sorting).
- Q20: Excel sheet column number: given a column title as appear in an excel sheet, return its corresponding column number. For example, A --> 1, Z --> 26, AA --> 27, CA --> 79, etc.

- Q1: Number of squared in an nxn matrix/board.
- Q2: Ugly Numbers (numbers whose prime factors only include 2, 3 & 5).
- Q3: Ugly Numbers 2: find the nth ugly number.
- Q4: Super ugly number (+ve numbers whose prime factors are only those present in a given list of prime numbers of size k).
- Q5: Find all duplicates in an array
- Q6: Find all numbers disappeared in an array: in an array, some elements appear twice and others appear once. Find all elements in the range [1..n] that do not appear in the array.
- Q7: Remove duplicates from Sorted List (II): given a sorted linked list, delete all nodes that have duplicate numbers.
- Q8: Angry kids problem (HackerRank).
- Q9: Count primes: count the number of primes less than a non-negative number n.
- Q10: Polymorphism in C++, pure virtual functions.
- Q11: Private and protected members in C++.
- Q12: Why C++ do not have 'finally' block? RAII (Resource Acquisition Is Initialization). RAII and Smart Pointers in C++, SBRM (Scope Bound Resource Management).
- Q13: Virtual Method Table (VTable), Virtual function Table, vptr
- Q14: What is the use of virtual functions? Open close principle. SOLID Principles in OOD.
- Q15: Thread safety of static variables.
- Q16: Single Number III: given an array in which exactly two elements appear only once and all other elements appear exactly twice. Find the two elements that appear only once.
- Q17: Single Number II: given an array where every element appears thrice except for one, which appears exactly once. Find that single one.
- Q18: Sum of two integers: calculate sum of two integers without using '+' and '-' operators.
- Q19: Find the nth-last node of a singly linked list using only one pass.
- Q20: Difference between Semaphore and Mutex.

- Q1: Difference between HTTP Get, Post and Put methods.
- Q2: Valid Sudoku: determine if a partially filled Sudoku is valid.
- Q3: Minimum index sum of two lists
- Q4: Line reflection: given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given points. Could you do it better than O(n^2).
- Q5: Number of Boomerangs: given n points in a plane, find tuple of points (i, j, k) such that distance between i & j is same as the distance between i & k.
- Q6: Remove element: given an array and a value, remove all instances of that value in place and return the new lenght.
- Q7: Remove linked list elements: remove all elements from a linked list of integers that have the value val.
- Q8: Summary ranges: given a sorted array without duplicates, return the summary of its ranges. Give [0, 1, 2, 4, 5, 7], return ["0->2", "4->5", "7"]
- Q9: Missing ranges: given a sorted integer array where the range of elements are in the inclusive range [lower, upper], return the missing ranges. Given [0, 1, 3, 50, 75], return ["2", "4->49", "51->74", "76->99"]
- Q10: Convert to Hexadecimal.
- Q11: Total hamming distance
- Q12: Longest uncommon subsequence 1: given a group of strings, find the longest uncommon subsequence of this group of two strings.
- Q13: Relative ranks: given scores of N atheletes, find their relative ranks and the people with the top three highest scores who will be awarded medals.
- Q14: Array partition 1: given an array of 2n integers, group these integers into n pairs of integers (a1, b1), (a2, b2),... (an, bn) which makes the sum if (ai, bi) as large as possible.
- Q15: Lonely Pixel 1: given a picture consisting of lack and white pixels, find the number of black lonely pixels. The picture is represented as a 2D character array consisting of B and W. Black lonely pixel is a B that is located at a specific position where the same row and the same column don't have any other black pixel.
- Q16: Largest rectangle in Histogram
- Q17: Maximal rectangle: given a 2D binary matrix filled with 0s and 1s, find the largest rectangle containing only 1s and return its area.
- Q18: Construct string from binary tree. The string is represented as paranthesized version of the tree.
- Q19: Happy number: write an algorithm to determine whether a number is happy. Eg. 19 --> 1^2+9^2 = 82 --> 8^2+2^2 = 68 --> 6^2+8^2 = 100 --> 1^2+0^2+0^2 = 1. So, 19 is happy.
- Q20: Linked list cycle II: given a linked list, return the node where the cycle begins. If there is no cycle, return null.

- Q1: Number of Connected Components in an Undirected Graph.
- Q2: Friend Circles.
- Q3: Spiral Matrix II
- Q4: Graph valid tree: given n nodes & a list of undirected edges, write a function to check whether these edges make make up a valid tree.
- Q5: Soft characters by frequency: given a string, sort it in decreasing order based on the frequency of characters.
- Q6: Sum of left leaves: find the sum of all left leaves in a given binary tree.
- Q7: Beautiful arrangement (google qn).
- Q8: Heaters: you are given positions of heaters and houses on a horizontal line; find out the minimum radius of heaters so that all houses could be covered by those heaters.
- Q9: Kill Process: given n processes, each with it's own unique PID and PPID. Return list of processes that will be killed if given the PID of a process that you want to kill.
- Q10: Generate parenthesis: given n, write a function to generate all valid combinations of well-formed n-pair parenthesis.
- Q11: Letter combinations of a phone number.
- Q12: Tader profit: stock sell-buy problem (from Hackerrank contest).
- Q13: Time Series query: for stock prices (from Hackerrank contest).
- Q14: License key formatting
- Q15: Gray code
- Q16: Compare version numbers.
- Q17: Rotate list: given a list, rotate the list to the right by k places.
- Q18: Palindrome number.
- Q19: Isomorphic Strings: given two strings s & t, determine if they are isomorphic.
- Q20: Zig zag conversion.

- Q1: Elevator algorithm
- Q2: Range Sum Query 2D - Immutable: find the sum of elements defined inside the rectangle defined by its upper left corner and lower right corner.
- Q3: Range Sum Query - Immutable: given an integer array, find the sum of elements between indices i and j inclusive.
- Q4: Rectangle Area: find the total area covered by two rectilinear rectangles in a 2D plane.
- Q5: Arithmetic slices
- Q6: Binary Tree Zig-Zag level order traversal.
- Q7: Average of levels in binary tree: given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.
- Q8: Add one row to tree: given the root of a binary tree, value v and a depth d, add a row to the nodes with value v at the given depth d.
- Q9: Contiguous array: given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.
- Q10: Contiguous subarray sum: given a list of non-negative numbers and a target integer k, write a function to check if the array has a contiguous subarray of size at least 2 that sums up to the multile of k.
- Q11: Decode string: for example, 3[a]2[bc] should return "aaabcbc".
- Q12: Counting bits: given a non-negative integer number, for even number in the range 0 to num, calculate the number of 1s in their binary representation.
- Q13: Integer to Roman
- Q14: Find the median from data stream.
- Q15: Roman to integer.
- Q16: Bit-wise AND of number ranges.
- Q17: Binary number with alternating bits.
- Q18: Brick wall: draw a vertical line from top to the bottom of the wall such that it crosses least number of bricks.
- Q19: Bulb switcher: there are n bulbs that an initially off. You first turn on all the bulbs. Then you turn off every second buld. On the third round, you toggle every third bulb. And for the ith round, you toggle every ith bulb. Find how many bulbs are in the ON state after n rounds.
- Q20: Find duplicate file in system: given a list of directory paths and all the files with contents in this directory, you need to find out, all the groups of duplicate files in the file system in terms of their paths.

- Q1: Basic Calculator 2: Implement a basic calculator to evaluate a simple expression string (contains only non-negative integers and operators +, -, *, / and spaces).
- Q2: Diagonal Traverse: return all elements of a matrix in diagonal order
- Q3: Top K frequent words
- Q4: Validate IP address (IPV4 and IPV6).
- Q5: Delete node in a BST
- Q6: Search insert position: given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
- Q7: Unique Binary Search Trees: given n, how many structurally unique BSTs can you create that stores integers 1 to n? [Catalan number]
- Q8: Different ways to add parentheses: given a string of numbers and operators, return all possible results from computing all different possible ways to group numbers and operators. For example, 2-1-1 could be grouped as ((2-1)-1) = 0 or as (2-(1-1)) = 2.
- Q9: Valid parentheses string: given a string containing only three types of characters: '(', ')' and '*', write a function to check whether this string is valid. '*' could be treated as a single right-parentheses or a single left-parentheses or as an empty string.
- Q10: Pacific-Atlantic water flow: given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the pacific ocean touches the left and top edges of the matrix and the atlantic ocean touches the right and bottom edges. Water can only flow in four directions and from a cell to another with height equal to or lower. Find the list of grid coordinates where water can flow to both pacific and Atlantic ocean.
- Q11: Fraction to recurring decimal: given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fraction is repeating, enclose the repeating part in parentheses.
- Q12: Magical string
- Q13: Teemo attacking
- Q14: 132 pattern
- Q15: Serialize and deserialize a BST.
- Q16: Shuffle an array: shuffle a set of numbers without duplicates.
- Q17: Bulls and Cows: write a function to return a hint according to the secret number and friend's guess.
- Q18: Set matrix to zeroes: given an m x n matrix, if an element is zero, set it's entire row and column to 0.
- Q19: Island perimeter: determine the permeter of an element represented by a matrix of 1st and 0s.
- Q20: Minimum time difference: given a list of 24 hour clock time points in HH:MM format, find the minimum minutes difference between any two points in the list.

Sample Technical Interview Questions

Last Updated: Jun 2018