Sorted of problems that appear in real interviews.
Last updated: October 2, 2017
Google (214)534 Design TinyURL388 Longest Absolute File Path683 K Empty Slots340 Longest Substring with At Most K Distinct Characters681 Next Closest Time482 License Key Formatting308 Range Sum Query 2D – Mutable298 Binary Tree Longest Consecutive Sequence346 Moving Average from Data Stream418 Sentence Screen Fitting281 Zigzag Iterator425 Word Squares361 Bomb Enemy394 Decode String393 UTF-8 Validation163 Missing Ranges66 Plus One568 Maximum Vacation Days317 Shortest Distance from All Buildings351 Android Unlock Patterns271 Encode and Decode Strings288 Unique Word Abbreviation289 Game of Life200 Number of Islands305 Number of Islands II259 3Sum Smaller280 Wiggle Sort246 Strobogrammatic Number417 Pacific Atlantic Water Flow218 The Skyline Problem279 Perfect Squares406 Queue Reconstruction by Height329 Longest Increasing Path in a Matrix159 Longest Substring with At Most Two Distinct Characters345 Reverse Vowels of a String56 Merge Intervals247 Strobogrammatic Number II524 Longest Word in Dictionary through Deleting399 Evaluate Division284 Peeking Iterator391 Perfect Rectangle407 Trapping Rain Water II286 Walls and Gates228 Summary Ranges297 Serialize and Deserialize Binary Tree294 Flip Game II146 LRU Cache471 Encode String with Shortest Length362 Design Hit Counter463 Island Perimeter616 Add Bold Tag in String380 Insert Delete GetRandom O(1)320 Generalized Abbreviation401 Binary Watch295 Find Median from Data Stream42 Trapping Rain Water249 Group Shifted Strings341 Flatten Nested List Iterator276 Paint Fence360 Sort Transformed Array411 Minimum Unique Word Abbreviation315 Count of Smaller Numbers After Self465 Optimal Account Balancing266 Palindrome Permutation253 Meeting Rooms II269 Alien Dictionary389 Find the Difference239 Sliding Window Maximum128 Longest Consecutive Sequence679 24 Game274 H-Index293 Flip Game20 Valid Parentheses359 Logger Rate Limiter505 The Maze II490 The Maze139 Word Break270 Closest Binary Search Tree Value162 Find Peak Element318 Maximum Product of Word Lengths212 Word Search II230 Kth Smallest Element in a BST158 Read N Characters Given Read4 II – Call multiple times684 Redundant Connection415 Add Strings369 Plus One Linked List400 Nth Digit587 Erect the Fence422 Valid Word Square240 Search a 2D Matrix II10 Regular Expression Matching358 Rearrange String k Distance Apart23 Merge k Sorted Lists498 Diagonal Traverse251 Flatten 2D Vector332 Reconstruct Itinerary373 Find K Pairs with Smallest Sums4 Median of Two Sorted Arrays155 Min Stack140 Word Break II484 Find Permutation173 Binary Search Tree Iterator17 Letter Combinations of a Phone Number324 Wiggle Sort II409 Longest Palindrome31 Next Permutation54 Spiral Matrix327 Count of Range Sum22 Generate Parentheses336 Palindrome Pairs57 Insert Interval166 Fraction to Recurring Decimal133 Clone Graph460 LFU Cache224 Basic Calculator44 Wildcard Matching231 Power of Two363 Max Sum of Rectangle No Larger Than K354 Russian Doll Envelopes421 Maximum XOR of Two Numbers in an Array50 Pow(x, n)348 Design Tic-Tac-Toe444 Sequence Reconstruction503 Next Greater Element II208 Implement Trie (Prefix Tree)501 Find Mode in Binary Search Tree309 Best Time to Buy and Sell Stock with Cooldown402 Remove K Digits382 Linked List Random Node475 Heaters551 Student Attendance Record I272 Closest Binary Search Tree Value II377 Combination Sum IV214 Shortest Palindrome302 Smallest Rectangle Enclosing Black Pixels379 Design Phone Directory353 Design Snake Game459 Repeated Substring Pattern542 01 Matrix375 Guess Number Higher or Lower II486 Predict the Winner543 Diameter of Binary Tree356 Line Reflection397 Integer Replacement282 Expression Add Operators408 Valid Word Abbreviation321 Create Maximum Number368 Largest Divisible Subset530 Minimum Absolute Difference in BST313 Super Ugly Number331 Verify Preorder Serialization of a Binary Tree323 Number of Connected Components in an Undirected Graph261 Graph Valid Tree451 Sort Characters By Frequency374 Guess Number Higher or Lower378 Kth Smallest Element in a Sorted Matrix448 Find All Numbers Disappeared in an Array310 Minimum Height Trees326 Power of Three257 Binary Tree Paths370 Range Addition643 Maximum Average Subarray I485 Max Consecutive Ones638 Shopping Offers483 Smallest Good Base686 Repeated String Match481 Magical String480 Sliding Window Median604 Design Compressed String Iterator474 Ones and Zeroes 38357 Count Numbers with Unique Digits685 Redundant Connection II469 Convex Polygon583 Delete Operation for Two Strings581 Shortest Unsorted Continuous Subarray569 Median Employee Salary689 Maximum Sum of 3 Non-Overlapping Subarrays562 Longest Line of Consecutive One in Matrix560 Subarray Sum Equals K447 Number of Boomerangs552 Student Attendance Record II676 Implement Magic Dictionary549 Binary Tree Longest Consecutive Sequence II330 Patching Array545 Boundary of Binary Tree544 Output Contest Matches668 Kth Smallest Number in Multiplication Table667 Beautiful Arrangement II541 Reverse String II535 Encode and Decode TinyURL665 Non-decreasing Array533 Lonely Pixel II531 Lonely Pixel I316 Remove Duplicate Letters659 Split Array into Consecutive Subsequences314 Binary Tree Vertical Order Traversal527 Word Abbreviation312 Burst Balloons526 Beautiful Arrangement658 Find K Closest Elements522 Longest Uncommon Subsequence II521 Longest Uncommon Subsequence I520 Detect Capital514 Freedom Trail506 Relative Ranks657 Judge Route Circle656 Coin Path652 Find Duplicate Subtrees651 4 Keys Keyboard494 Target Sum493 Reverse Pairs644 Maximum Average Subarray II487 Max Consecutive Ones II687 Longest Univalue PathFacebook (111)534 Design TinyURL283 Move Zeroes301 Remove Invalid Parentheses273 Integer to English Words325 Maximum Size Subarray Sum Equals k67 Add Binary621 Task Scheduler253 Meeting Rooms II17 Letter Combinations of a Phone Number311 Sparse Matrix Multiplication91 Decode Ways 19.8%297 Serialize and Deserialize Binary Tree314 Binary Tree Vertical Order Traversal10 Regular Expression Matching15 3Sum158 Read N Characters Given Read4 II – Call multiple times278 First Bad Version277 Find the Celebrity200 Number of Islands76 Minimum Window Substring257 Binary Tree Paths282 Expression Add Operators23 Merge k Sorted Lists157 Read N Characters Given Read4121 Best Time to Buy and Sell Stock602 Friend Requests II: Who Has the Most Friends56 Merge Intervals161 One Edit Distance173 Binary Search Tree Iterator1 Two Sum543 Diameter of Binary Tree211 Add and Search Word – Data structure design341 Flatten Nested List Iterator252 Meeting Rooms125 Valid Palindrome597 Friend Requests I: Overall Acceptance Rate139 Word Break636 Exclusive Time of Functions285 Inorder Successor in BST78 Subsets98 Validate Binary Search Tree43 Multiply Strings75 Sort Colors670 Maximum Swap57 Insert Interval133 Clone Graph215 Kth Largest Element in an Array33 Search in Rotated Sorted Array13 Roman to Integer206 Reverse Linked List79 Word Search494 Target Sum236 Lowest Common Ancestor of a Binary Tree398 Random Pick Index477 Total Hamming Distance38 Count and Say680 Valid Palindrome II49 Group Anagrams88 Merge Sorted Array218 The Skyline Problem146 LRU Cache238 Product of Array Except Self209 Minimum Size Subarray Sum102 Binary Tree Level Order Traversal90 Subsets II71 Simplify Path286 Walls and Gates128 Longest Consecutive Sequence639 Decode Ways II523 Continuous Subarray Sum334 Increasing Triplet Subsequence208 Implement Trie (Prefix Tree)28 Implement strStr()269 Alien Dictionary127 Word Ladder647 Palindromic Substrings377 Combination Sum IV20 Valid Parentheses44 Wildcard Matching554 Brick Wall235 Lowest Common Ancestor of a Binary Search Tree380 Insert Delete GetRandom O(1)50 Pow(x, n)117 Populating Next Right Pointers in Each Node II69 Sqrt(x)461 Hamming Distance85 Maximal Rectangle210 Course Schedule II26 Remove Duplicates from Sorted Array68 Text Justification221 Maximal Square274 H-Index404 Sum of Left Leaves25 Reverse Nodes in k-Group234 Palindrome Linked List689 Maximum Sum of 3 Non-Overlapping Subarrays80 Remove Duplicates from Sorted Array II168 Excel Sheet Column Title261 Graph Valid Tree265 Paint House II275 H-Index II410 Split Array Largest Sum525 Contiguous Array674 Longest Continuous Increasing Subsequence572 Subtree of Another Tree578 Get Highest Answer Rate Question637 Average of Levels in Binary Tree642 Design Search Autocomplete System653 Two Sum IV – Input is a BST673 Number of Longest Increasing Subsequence535 Encode and Decode TinyURLMicrosoft (92)138 Copy List with Random Pointer348 Design Tic-Tac-Toe206 Reverse Linked List419 Battleships in a Board273 Integer to English Words171 Excel Sheet Column Number54 Spiral Matrix88 Merge Sorted Array445 Add Two Numbers II236 Lowest Common Ancestor of a Binary Tree200 Number of Islands53 Maximum Subarray1 Two Sum235 Lowest Common Ancestor of a Binary Search Tree186 Reverse Words in a String II218 The Skyline Problem21 Merge Two Sorted Lists116 Populating Next Right Pointers in Each Node103 Binary Tree Zigzag Level Order Traversal297 Serialize and Deserialize Binary Tree238 Product of Array Except Self121 Best Time to Buy and Sell Stock268 Missing Number48 Rotate Image75 Sort Colors151 Reverse Words in a String13 Roman to Integer73 Set Matrix Zeroes117 Populating Next Right Pointers in Each Node II20 Valid Parentheses141 Linked List Cycle2 Add Two Numbers33 Search in Rotated Sorted Array168 Excel Sheet Column Title24 Swap Nodes in Pairs8 String to Integer (atoi)237 Delete Node in a Linked List146 LRU Cache232 Implement Queue using Stacks173 Binary Search Tree Iterator98 Validate Binary Search Tree208 Implement Trie (Prefix Tree)174 Dungeon Game212 Word Search II4 Median of Two Sorted Arrays5 Longest Palindromic Substring285 Inorder Successor in BST153 Find Minimum in Rotated Sorted Array26 Remove Duplicates from Sorted Array160 Intersection of Two Linked Lists106 Construct Binary Tree from Inorder and Postorder Traversal102 Binary Tree Level Order Traversal23 Merge k Sorted Lists25 Reverse Nodes in k-Group215 Kth Largest Element in an Array189 Rotate Array191 Number of 1 Bits567 Permutation in String71 Simplify Path387 First Unique Character in a String15 3Sum204 Count Primes56 Merge Intervals94 Binary Tree Inorder Traversal165 Compare Version Numbers28 Implement strStr()46 Permutations300 Longest Increasing Subsequence91 Decode Ways101 Symmetric Tree270 Closest Binary Search Tree Value114 Flatten Binary Tree to Linked List79 Word Search258 Add Digits125 Valid Palindrome124 Binary Tree Maximum Path Sum162 Find Peak Element112 Path Sum654 Maximum Binary Tree333 Largest BST Subtree365 Water and Jug Problem452 Minimum Number of Arrows to Burst Balloons47 Permutations II513 Find Bottom Left Tree Value213 House Robber II55 Jump Game591 Tag Validator631 Design Excel Sum Formula642 Design Search Autocomplete System650 2 Keys Keyboard651 4 Keys Keyboard672 Bulb Switcher IIAmazon (88)534 Design TinyURL675 Cut Off Trees for Golf Event1 Two Sum20 Valid Parentheses146 LRU Cache438 Find All Anagrams in a String200 Number of Islands48 Rotate Image297 Serialize and Deserialize Binary Tree138 Copy List with Random Pointer236 Lowest Common Ancestor of a Binary Tree460 LFU Cache387 First Unique Character in a String121 Best Time to Buy and Sell Stock239 Sliding Window Maximum5 Longest Palindromic Substring17 Letter Combinations of a Phone Number238 Product of Array Except Self42 Trapping Rain Water682 Baseball Game127 Word Ladder380 Insert Delete GetRandom O(1)235 Lowest Common Ancestor of a Binary Search Tree206 Reverse Linked List23 Merge k Sorted Lists155 Min Stack2 Add Two Numbers98 Validate Binary Search Tree449 Serialize and Deserialize BST240 Search a 2D Matrix II234 Palindrome Linked List517 Super Washing Machines215 Kth Largest Element in an Array139 Word Break21 Merge Two Sorted Lists49 Group Anagrams126 Word Ladder II3 Longest Substring Without Repeating Characters242 Valid Anagram529 Minesweeper160 Intersection of Two Linked Lists141 Linked List Cycle186 Reverse Words in a String II167 Two Sum II – Input array is sorted15 3Sum78 Subsets535 Encode and Decode TinyURL73 Set Matrix Zeroes102 Binary Tree Level Order Traversal508 Most Frequent Subtree Sum8 String to Integer (atoi)538 Convert BST to Greater Tree204 Count Primes199 Binary Tree Right Side View414 Third Maximum Number89 Gray Code451 Sort Characters By Frequency355 Design Twitter 2119 Pascal’s Triangle II662 Maximum Width of Binary Tree645 Set Mismatch617 Merge Two Binary Trees661 Image Smoother396 Rotate Function646 Maximum Length of Pair Chain545 Boundary of Binary Tree606 Construct String from Binary Tree640 Solve the Equation663 Equal Tree Partition459 Repeated Substring Pattern516 Longest Palindromic Subsequence532 K-diff Pairs in an Array579 Find Cumulative Salary of an Employee536 Construct Binary Tree from String537 Complex Number Multiplication553 Optimal DivisionBloomberg (66)445 Add Two Numbers II121 Best Time to Buy and Sell Stock138 Copy List with Random Pointer582 Kill Process1 Two Sum283 Move Zeroes387 First Unique Character in a String155 Min Stack20 Valid Parentheses146 LRU Cache117 Populating Next Right Pointers in Each Node II206 Reverse Linked List50 Pow(x, n)56 Merge Intervals62 Unique Paths42 Trapping Rain Water69 Sqrt(x)160 Intersection of Two Linked Lists122 Best Time to Buy and Sell Stock II2 Add Two Numbers268 Missing Number53 Maximum Subarray98 Validate Binary Search Tree287 Find the Duplicate Number7 Reverse Integer49 Group Anagrams232 Implement Queue using Stacks386 Lexicographical Numbers151 Reverse Words in a String215 Kth Largest Element in an Array88 Merge Sorted Array103 Binary Tree Zigzag Level Order Traversal3 Longest Substring Without Repeating Characters102 Binary Tree Level Order Traversal208 Implement Trie (Prefix Tree)139 Word Break225 Implement Stack using Queues105 Construct Binary Tree from Preorder and Inorder Traversal230 Kth Smallest Element in a BST141 Linked List Cycle13 Roman to Integer26 Remove Duplicates from Sorted Array5 Longest Palindromic Substring63 Unique Paths II 38 String to Integer (atoi)297 Serialize and Deserialize Binary Tree101 Symmetric Tree172 Factorial Trailing Zeroes79 Word Search33 Search in Rotated Sorted Array100 Same Tree189 Rotate Array15 3Sum158 Read N Characters Given Read4 II – Call multiple times24 Swap Nodes in Pairs570 Managers with at Least 5 Direct Reports16 3Sum Closest131 Palindrome Partitioning266 Palindrome Permutation11 Container With Most Water547 Friend Circles556 Next Greater Element III113 Path Sum II110 Balanced Binary Tree274 H-Index669 Trim a Binary Search TreeUber (52)380 Insert Delete GetRandom O(1)262 Trips and Users291 Word Pattern II254 Factor Combinations36 Valid Sudoku297 Serialize and Deserialize Binary Tree432 All O`one Data Structure139 Word Break146 LRU Cache249 Group Shifted Strings22 Generate Parentheses535 Encode and Decode TinyURL17 Letter Combinations of a Phone Number54 Spiral Matrix133 Clone Graph 249 Group Anagrams450 Delete Node in a BST290 Word Pattern13 Roman to Integer186 Reverse Words in a String II208 Implement Trie (Prefix Tree)10 Regular Expression Matching37 Sudoku Solver138 Copy List with Random Pointer23 Merge k Sorted Lists39 Combination Sum140 Word Break II230 Kth Smallest Element in a BST207 Course Schedule91 Decode Ways1 Two Sum337 House Robber III33 Search in Rotated Sorted Array161 One Edit Distance242 Valid Anagram78 Subsets76 Minimum Window Substring24 Swap Nodes in Pairs202 Happy Number121 Best Time to Buy and Sell Stock206 Reverse Linked List125 Valid Palindrome104 Maximum Depth of Binary Tree534 Design TinyURL516 Longest Palindromic Subsequence373 Find K Pairs with Smallest Sums266 Palindrome Permutation171 Excel Sheet Column Number690 Employee Importance648 Replace Words8 String to Integer (atoi)155 Min StackLinkedIn (48)339 Nested List Weight Sum244 Shortest Word Distance II364 Nested List Weight Sum II170 Two Sum III – Data structure design256 Paint House156 Binary Tree Upside Down243 Shortest Word Distance254 Factor Combinations245 Shortest Word Distance III366 Find Leaves of Binary Tree205 Isomorphic Strings297 Serialize and Deserialize Binary Tree53 Maximum Subarray605 Can Place Flowers65 Valid Number50 Pow(x, n)149 Max Points on a Line68 Text Justification277 Find the Celebrity56 Merge Intervals187 Repeated DNA Sequences311 Sparse Matrix Multiplication236 Lowest Common Ancestor of a Binary Tree102 Binary Tree Level Order Traversal34 Search for a Range464 Can I Win1 Two Sum152 Maximum Product Subarray150 Evaluate Reverse Polish Notation33 Search in Rotated Sorted Array46 Permutations76 Minimum Window Substring238 Product of Array Except Self104 Maximum Depth of Binary Tree127 Word Ladder101 Symmetric Tree57 Insert Interval103 Binary Tree Zigzag Level Order Traversal198 House Robber23 Merge k Sorted Lists21 Merge Two Sorted Lists47 Permutations II173 Binary Search Tree Iterator633 Sum of Square Numbers367 Valid Perfect Square515 Find Largest Value in Each Tree Row671 Second Minimum Node In a Binary Tree647 Palindromic SubstringsTwitter (34)433 Minimum Genetic Mutation608 Tree Node585 Investments in 2016296 Best Meeting Point586 Customer Placing the Largest Number of Orders468 Validate IP Address580 Count Student Number in Departments341 Flatten Nested List Iterator269 Alien Dictionary355 Design Twitter251 Flatten 2D Vector12 Integer to Roman218 The Skyline Problem161 One Edit Distance146 LRU Cache202 Happy Number140 Word Break II149 Max Points on a Line208 Implement Trie (Prefix Tree)60 Permutation Sequence20 Valid Parentheses42 Trapping Rain Water10 Regular Expression Matching235 Lowest Common Ancestor of a Binary Search Tree56 Merge Intervals206 Reverse Linked List23 Merge k Sorted Lists43 Multiply Strings44 Wildcard Matching118 Pascal’s Triangle380 Insert Delete GetRandom O(1)378 Kth Smallest Element in a Sorted Matrix323 Number of Connected Components in an Undirected Graph407 Trapping Rain Water IIApple (29)238 Product of Array Except Self1 Two Sum42 Trapping Rain Water206 Reverse Linked List191 Number of 1 Bits237 Delete Node in a Linked List284 Peeking Iterator240 Search a 2D Matrix II48 Rotate Image149 Max Points on a Line102 Binary Tree Level Order Traversal236 Lowest Common Ancestor of a Binary Tree70 Climbing Stairs36 Valid Sudoku215 Kth Largest Element in an Array4 Median of Two Sorted Arrays104 Maximum Depth of Binary Tree28 Implement strStr()190 Reverse Bits7 Reverse Integer221 Maximal Square165 Compare Version Numbers151 Reverse Words in a String207 Course Schedule257 Binary Tree Paths69 Sqrt(x)21 Merge Two Sorted Lists118 Pascal’s Triangle383 Ransom NoteSnapchat (26)36 Valid Sudoku289 Game of Life253 Meeting Rooms II269 Alien Dictionary403 Frog Jump37 Sudoku Solver314 Binary Tree Vertical Order Traversal127 Word Ladder146 LRU Cache140 Word Break II161 One Edit Distance377 Combination Sum IV96 Unique Binary Search Trees206 Reverse Linked List39 Combination Sum76 Minimum Window Substring155 Min Stack44 Wildcard Matching151 Reverse Words in a String402 Remove K Digits270 Closest Binary Search Tree Value527 Word Abbreviation40 Combination Sum II312 Burst Balloons439 Ternary Expression Parser635 Design Log Storage SystemAirbnb (23)336 Palindrome Pairs251 Flatten 2D Vector269 Alien Dictionary68 Text Justification1 Two Sum198 House Robber212 Word Search II219 Contains Duplicate II10 Regular Expression Matching202 Happy Number108 Convert Sorted Array to Binary Search Tree136 Single Number2 Add Two Numbers160 Intersection of Two Linked Lists217 Contains Duplicate190 Reverse Bits20 Valid Parentheses220 Contains Duplicate III385 Mini Parser221 Maximal Square23 Merge k Sorted Lists227 Basic Calculator II415 Add StringsZenefits (21)42 Trapping Rain Water52 N-Queens II255 Verify Preorder Sequence in Binary Search Tree317 Shortest Distance from All Buildings251 Flatten 2D Vector210 Course Schedule II206 Reverse Linked List109 Convert Sorted List to Binary Search Tree200 Number of Islands20 Valid Parentheses146 LRU Cache168 Excel Sheet Column Title155 Min Stack4 Median of Two Sorted Arrays125 Valid Palindrome207 Course Schedule239 Sliding Window Maximum229 Majority Element II22 Generate Parentheses261 Graph Valid Tree169 Majority ElementYelp (17)599 Minimum Index Sum of Two Lists56 Merge Intervals564 Find the Closest Palindrome347 Top K Frequent Elements49 Group Anagrams218 The Skyline Problem14 Longest Common Prefix127 Word Ladder207 Course Schedule1 Two Sum3 Longest Substring Without Repeating Characters380 Insert Delete GetRandom O(1)206 Reverse Linked List126 Word Ladder II242 Valid Anagram151 Reverse Words in a String381 Insert Delete GetRandom O(1) – Duplicates allowedYahoo (14)1 Two Sum479 Largest Palindrome Product13 Roman to Integer217 Contains Duplicate297 Serialize and Deserialize Binary Tree146 LRU Cache139 Word Break4 Median of Two Sorted Arrays284 Peeking Iterator206 Reverse Linked List141 Linked List Cycle104 Maximum Depth of Binary Tree491 Increasing Subsequences624 Maximum Distance in ArraysPocket Gems (13)347 Top K Frequent Elements75 Sort Colors28 Implement strStr()285 Inorder Successor in BST269 Alien Dictionary133 Clone Graph214 Shortest Palindrome215 Kth Largest Element in an Array139 Word Break380 Insert Delete GetRandom O(1)442 Find All Duplicates in an Array424 Longest Repeating Character Replacement600 Non-negative Integers without Consecutive OnesAdobe (12)1 Two Sum195 Tenth Line2 Add Two Numbers292 Nim Game237 Delete Node in a Linked List4 Median of Two Sorted Arrays3 Longest Substring Without Repeating Characters206 Reverse Linked List258 Add Digits15 3Sum169 Majority Element70 Climbing Stairs