tvl-depot/scratch/facebook/leetcode.org
William Carroll 93d7b5d8ea Solve a few String questions
Valid Anagram

This one is a classic: `sorted(a) == sorted(b)`

Group Anagrams

Using product of prime numbers to create a key for anagrams is much faster than
sorting the characters in each word. It is also satisfyingly simple.

Encode and Decode Strings

My initial implementation was clumsy and prone to fail for edge-cases. A more
elegant solution is using something like:

```python
def encode(words):
  return "".join("{}:{}".format(len(x), x) for x in words)
```
2020-12-25 03:52:54 +00:00

163 lines
6.7 KiB
Org Mode

# This list is from:
# https://www.teamblind.com/post/New-Year-Gift---Curated-List-of-Top-100-LeetCode-Questions-to-Save-Your-Time-OaM1orEU
* Array
** DONE Two Sum
https://leetcode.com/problems/two-sum/
** DONE Best Time to Buy and Sell Stock
https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
** DONE Contains Duplicate
https://leetcode.com/problems/contains-duplicate/
** DONE Product of Array Except Self
https://leetcode.com/problems/product-of-array-except-self/
** DONE Maximum Subarray
https://leetcode.com/problems/maximum-subarray/
** DONE Maximum Product Subarray
https://leetcode.com/problems/maximum-product-subarray/
** DONE Find Minimum in Rotated Sorted Array
https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/
** DONE Search in Rotated Sorted Array
https://leetcode.com/problems/search-in-rotated-sorted-array/
** DONE 3Sum
https://leetcode.com/problems/3sum/
** DONE Container With Most Water
https://leetcode.com/problems/container-with-most-water/
* Binary
** DONE Sum of Two Integers
https://leetcode.com/problems/sum-of-two-integers/
** DONE Number of 1 Bits
https://leetcode.com/problems/number-of-1-bits/
** TODO Counting Bits
https://leetcode.com/problems/counting-bits/
** DONE Missing Number
https://leetcode.com/problems/missing-number/
** TODO Reverse Bits
https://leetcode.com/problems/reverse-bits/
* Dynamic Programming
** DONE Climbing Stairs
https://leetcode.com/problems/climbing-stairs/
** TODO Coin Change
https://leetcode.com/problems/coin-change/
** TODO Longest Increasing Subsequence
https://leetcode.com/problems/longest-increasing-subsequence/
** TODO Longest Common Subsequence
** DONE Word Break Problem
https://leetcode.com/problems/word-break/
** TODO Combination Sum
https://leetcode.com/problems/combination-sum-iv/
** TODO House Robber
https://leetcode.com/problems/house-robber/
** TODO House Robber II
https://leetcode.com/problems/house-robber-ii/
** TODO Decode Ways
https://leetcode.com/problems/decode-ways/
** TODO Unique Paths
https://leetcode.com/problems/unique-paths/
** TODO Jump Game
https://leetcode.com/problems/jump-game/
* Graph
** DONE Clone Graph
https://leetcode.com/problems/clone-graph/
** DONE Course Schedule
https://leetcode.com/problems/course-schedule/
** TODO Pacific Atlantic Water Flow
https://leetcode.com/problems/pacific-atlantic-water-flow/
** DONE Number of Islands
https://leetcode.com/problems/number-of-islands/
** TODO Longest Consecutive Sequence
https://leetcode.com/problems/longest-consecutive-sequence/
** TODO Alien Dictionary (Leetcode Premium)
https://leetcode.com/problems/alien-dictionary/
** TODO Graph Valid Tree (Leetcode Premium)
https://leetcode.com/problems/graph-valid-tree/
** DONE Number of Connected Components in an Undirected Graph (Leetcode Premium)
https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/
* Interval
** TODO Insert Interval
https://leetcode.com/problems/insert-interval/
** DONE Merge Intervals
https://leetcode.com/problems/merge-intervals/
** TODO No Overlapping Intervals
https://leetcode.com/problems/non-overlapping-intervals/
** DONE Meeting Rooms (Leetcode Premium)
https://leetcode.com/problems/meeting-rooms/
** TODO Meeting Rooms II (Leetcode Premium)
https://leetcode.com/problems/meeting-rooms-ii/
* Linked List
** DONE Reverse a Linked List
https://leetcode.com/problems/reverse-linked-list/
** DONE Detect Cycle in a Linked List
https://leetcode.com/problems/linked-list-cycle/
** DONE Merge Two Sorted Lists
https://leetcode.com/problems/merge-two-sorted-lists/
** DONE Merge K Sorted Lists
https://leetcode.com/problems/merge-k-sorted-lists/
** DONE Remove Nth Node From End Of List
https://leetcode.com/problems/remove-nth-node-from-end-of-list/
** DONE Reorder List
https://leetcode.com/problems/reorder-list/
* Matrix
** DONE Set Matrix Zeroes
https://leetcode.com/problems/set-matrix-zeroes/
** DONE Spiral Matrix
https://leetcode.com/problems/spiral-matrix/
** TODO Rotate Image
https://leetcode.com/problems/rotate-image/
** DONE Word Search
https://leetcode.com/problems/word-search/
* String
** TODO Longest Substring Without Repeating Characters
https://leetcode.com/problems/longest-substring-without-repeating-characters/
** TODO Longest Repeating Character Replacement
https://leetcode.com/problems/longest-repeating-character-replacement/
** TODO Minimum Window Substring
https://leetcode.com/problems/minimum-window-substring/
** DONE Valid Anagram
https://leetcode.com/problems/valid-anagram/
** DONE Group Anagrams
https://leetcode.com/problems/group-anagrams/
** DONE Valid Parentheses
https://leetcode.com/problems/valid-parentheses/
** DONE Valid Palindrome
https://leetcode.com/problems/valid-palindrome/
** TODO Longest Palindromic Substring
https://leetcode.com/problems/longest-palindromic-substring/
** TODO Palindromic Substrings
https://leetcode.com/problems/palindromic-substrings/
** DONE Encode and Decode Strings (Leetcode Premium)
https://leetcode.com/problems/encode-and-decode-strings/
* Tree
** DONE Maximum Depth of Binary Tree
https://leetcode.com/problems/maximum-depth-of-binary-tree/
** DONE Same Tree
https://leetcode.com/problems/same-tree/
** DONE Invert/Flip Binary Tree
https://leetcode.com/problems/invert-binary-tree/
** DONE Binary Tree Maximum Path Sum
https://leetcode.com/problems/binary-tree-maximum-path-sum/
** DONE Binary Tree Level Order Traversal
https://leetcode.com/problems/binary-tree-level-order-traversal/
** DONE Serialize and Deserialize Binary Tree
https://leetcode.com/problems/serialize-and-deserialize-binary-tree/
** DONE Subtree of Another Tree
https://leetcode.com/problems/subtree-of-another-tree/
** TODO Construct Binary Tree from Preorder and Inorder Traversal
https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
** TODO Validate Binary Search Tree
https://leetcode.com/problems/validate-binary-search-tree/
** TODO Kth Smallest Element in a BST
https://leetcode.com/problems/kth-smallest-element-in-a-bst/
** DONE Lowest Common Ancestor of BST
https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/
** DONE Implement Trie (Prefix Tree)
https://leetcode.com/problems/implement-trie-prefix-tree/
** DONE Add and Search Word
https://leetcode.com/problems/add-and-search-word-data-structure-design/
** DONE Word Search II
https://leetcode.com/problems/word-search-ii/
* Heap
** DONE Merge K Sorted Lists
https://leetcode.com/problems/merge-k-sorted-lists/
** DONE Top K Frequent Elements
https://leetcode.com/problems/top-k-frequent-elements/
** DONE Find Median from Data Stream
https://leetcode.com/problems/find-median-from-data-stream/