Skip to content

arjunmullick/coding-Interview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

These are the most popular coding interview questions, from easy to hard, in order.

The problems cover common patterns and algorithms in interviews:

  • Binary search
  • Two pointers
  • Backtracking
  • DFS
  • BFS
  • Dynamic programming
  • Stack / Greedy / Heap
  • Swap corresponding values
  • Store one or more different values in the same pointer
  • Trie / Map

Big O performance of common functions (Java).

List Add Remove Get Contains Next Data Structure
ArrayList O(1) O(n) O(1) O(n) O(1) Array
LinkedList O(1) O(1) O(n) O(n) O(1) Linked List
CopyOnWriteArrayList O(n) O(n) O(1) O(n) O(1) Array
Set Add Remove Contains Next Size Data Structure
HashSet O(1) O(1) O(1) O(h/n) O(1) Hash Table
LinkedHashSet O(1) O(1) O(1) O(1) O(1) Hash Table + Linked List
EnumSet O(1) O(1) O(1) O(1) O(1) Bit Vector
TreeSet O(log n) O(log n) O(log n) O(log n) O(1) Red-black tree
CopyOnWriteArraySet O(n) O(n) O(n) O(1) O(1) Array
ConcurrentSkipListSet O(log n) O(log n) O(log n) O(1) O(n) Skip List
Queue Offer Peak Poll Remove Size Data Structure
PriorityQueue O(log n) O(1) O(log n) O(n) O(1) Priority Heap
LinkedList O(1) O(1) O(1) O(1) O(1) Array
ArrayDequeue O(1) O(1) O(1) O(n) O(1) Linked List
ConcurrentLinkedQueue O(1) O(1) O(1) O(n) O(n) Linked List
ArrayBlockingQueue O(1) O(1) O(1) O(n) O(1) Array
PriorirityBlockingQueue O(log n) O(1) O(log n) O(n) O(1) Priority Heap
SynchronousQueue O(1) O(1) O(1) O(n) O(1) None!
DelayQueue O(log n) O(1) O(log n) O(n) O(1) Priority Heap
LinkedBlockingQueue O(1) O(1) O(1) O(n) O(1) Linked List
Map Get ContainsKey Next Data Structure
HashMap O(1) O(1) O(h / n) Hash Table
LinkedHashMap O(1) O(1) O(1) Hash Table + Linked List
IdentityHashMap O(1) O(1) O(h / n) Array
WeakHashMap O(1) O(1) O(h / n) Hash Table
EnumMap O(1) O(1) O(1) Array
TreeMap O(log n) O(log n) O(log n) Red-black tree
ConcurrentHashMap O(1) O(1) O(h / n) Hash Tables
ConcurrentSkipListMap O(log n) O(log n) O(1) Skip List

Reference :

14 Patterns to Ace Any Coding Interview Question

Coding Interview Question

Bonus Questions


Custom DataStructure


Questions By Topics


Graph

Graph
BFS DFS Topoligical Sort Union Find
Binary Tree Level Order Traversal II Minimum Depth of Binary Tree Course Schedule  Graph Valid Tree
Average of Levels in Binary Tree Same Tree Course Schedule II  Number of Connected Components in an Undirected Graph
Minimum Depth of Binary Tree Path Sum Minimum Height Trees Number of Islands
Clone Graph Diameter of Binary Tree  Alien Dictionary
Pacific Atlantic Water Flow Merge Two Binary Trees  Sequence Reconstruction
Number of Islands Maximum Depth of Binary Tree Sort Items by Groups Respecting Dependencies
 Graph Valid Tree Lowest Common Ancestor of a Binary Search Tree
 Number of Connected Components in an Undirected Graph Subtree of Another Tree
Course Schedule Invert Binary Tree
Course Schedule II Target Sum
Minimum Height Trees Clone Graph
Binary Tree Level Order Traversal Pacific Atlantic Water Flow
Binary Tree Zigzag Level Order Traversal Number of Islands
Populating Next Right Pointers in Each Node  Graph Valid Tree
Populating Next Right Pointers in Each Node II  Number of Connected Components in an Undirected Graph
Binary Tree Right Side View Kth Smallest Element in a BST
All Nodes Distance K in Binary Tree Course Schedule
Course Schedule II
Binary Tree Right Side View
All Nodes Distance K in Binary Tree
Path Sum II
Path Sum III
Lowest Common Ancestor of a Binary Tree
Maximum Binary Tree
Maximum Width of Binary Tree
Construct Binary Tree from Preorder and Inorder Traversal
Validate Binary Search Tree
Binary Tree Maximum Path Sum
Word Search II
Sort Items by Groups Respecting Dependencies

Recursion

Recursion
Backtracking DP Trie
Word Search Climbing Stairs Longest Word in Dictionary
Letter Case Permutation Best Time to Buy and Sell Stock  Index Pairs of a String
Subsets Maximum Subarray Implement Trie (Prefix Tree)
Subsets II Range Sum Query - Immutable Maximum XOR of Two Numbers in an Array
Permutations Target Sum Word Search II
Permutations II House Robber Concatenated Words
Combinations House Robber II Prefix and Suffix Search
Combination Sum Coin Change Palindrome Pairs
Combination Sum II Maximum Product Subarray  Design Search Autocomplete System
Combination Sum III Longest Increasing Subsequence  Word Squares
Generate Parentheses Longest Palindromic Substring
Palindrome Partitioning Word Break
Letter Combinations of a Phone Number Combination Sum IV
 Generalized Abbreviation Decode Ways
Sudoku Solver Unique Paths
N-Queens Jump Game
Palindromic Substrings
Number of Longest Increasing Subsequence
Partition Equal Subset Sum
Partition to K Equal Sum Subsets
Best Time to Buy and Sell Stock with Cooldown
Counting Bits

One Dimension

Arrays Binary Search Linked List / Pointers Sliding window
Contains Duplicate Binary Search Linked List Cycle Minimum Size Subarray Sum
Missing Number Find Smallest Letter Greater Than Target Middle of the Linked List Fruit Into Baskets
Find All Numbers Disappeared in an Array Peak Index in a Mountain Array Palindrome Linked List Permutation in String
Single Number Find the Duplicate Number Remove Linked List Elements Longest Repeating Character Replacement
Product of Array Except Self Kth Smallest Element in a Sorted Matrix Remove Duplicates from Sorted List Longest Substring Without Repeating Characters
Find the Duplicate Number Find Minimum in Rotated Sorted Array Linked List Cycle II Sliding Window Maximum
Find All Duplicates in an Array Find Peak Element Add Two Numbers Minimum Number of K Consecutive Bit Flips
Set Matrix Zeroes Search in Rotated Sorted Array Remove Nth Node From End Of List Count Unique Characters of All Substrings of a Given String
Spiral Matrix Search in Rotated Sorted Array II Sort List Minimum Window Substring
Rotate Image Search a 2D Matrix Reorder List Substring with Concatenation of All Words
First Missing Positive Search a 2D Matrix II Reverse Linked List
Longest Consecutive Sequence Find K Closest Elements Reverse Linked List II
Count of Range Sum Rotate List
Median of Two Sorted Arrays Swap Nodes in Pairs
Odd Even Linked List
Reverse Nodes in k-Group

Two Pointer / Two Choice

Heap / PriorityQueue Sliding Window Two Pointers
Task Scheduler Minimum Size Subarray Sum Merge Two Sorted Lists
Minimum Number of Arrows to Burst Balloons Fruit Into Baskets Two Sum
Reorganize String Permutation in String Squares of a Sorted Array
 Employee Free Time Longest Repeating Character Replacement Backspace String Compare
 Rearrange String k Distance Apart Longest Substring Without Repeating Characters Find the Duplicate Number
Course Schedule III Sliding Window Maximum 3 Sum
Kth Smallest Element in a Sorted Matrix Minimum Number of K Consecutive Bit Flips 3 Sum Closest
Find K Pairs with Smallest Sums Count Unique Characters of All Substrings of a Given String Subarrays with Product Less than K
 Meeting Rooms II Minimum Window Substring Sort Colours
Task Scheduler Substring with Concatenation of All Words Container With Most Water
K Closest Points to Origin Trapping Rain Water
Top K Frequent Elements
Sort Characters By Frequency
Kth Largest Element in an Array
Reorganize String
Merge k Sorted Lists
Smallest Range Covering Elements from K Lists
 Employee Free Time
 Rearrange String k Distance Apart
Course Schedule III
Maximum Frequency Stack
Find Median from Data Stream
Sliding Window Median
 Meeting Rooms
Merge Intervals
Interval List Intersections
Non-overlapping Intervals
 Meeting Rooms II
Insert Interval

Question by Concept

Arrays

Binary Search

Backtracking

Graph / Tree Search (BFS/DFS)

Trie

TreeMap and Interval Tree