Leetcode my posts


274. H-Index

2 lines C++ solution, easy to understand

https://leetcode.com/problems/h-index/discuss/359325/2-lines-C%2B%2B-solution-easy-to-understand


46. Permutations

C++ clear general backtracking, beats 98.38% in time, 100.00% in memory

https://leetcode.com/problems/permutations/discuss/359476/C%2B%2B-clear-general-backtracking-beats-98.38-in-time-100.00-in-memory


47. Permutations II

Explaining the “used” array trick

https://leetcode.com/problems/permutations-ii/discuss/360071/Explaining-the-%22used%22-array-trick


200. Number of Islands

C++ DFS solution & 2D Union Find solution

https://leetcode.com/problems/number-of-islands/discuss/448901/C%2B%2B-DFS-solution-and-2D-Union-Find-solution


912. Sort an Array

C++ merge, insertion, bubble, quick, heap

https://leetcode.com/problems/sort-an-array/discuss/448903/C%2B%2B-merge-insertion-bubble-quick-heap


111. Minimum Depth of Binary Tree

C++ BFS & DFS

https://leetcode.com/problems/minimum-depth-of-binary-tree/discuss/448904/C%2B%2B-BFS-and-DFS


113. Path Sum II

Passing current path by reference or not

https://leetcode.com/problems/path-sum-ii/discuss/448905/Passing-current-path-by-reference-or-not


114. Flatten Binary Tree to Linked List

comparison of traversal order dfs/bfs on binary tree

https://leetcode.com/problems/flatten-binary-tree-to-linked-list/discuss/448906/comparison-of-traversal-order-dfsbfs-on-binary-tree


General discussion

Can I use non-const references in C++ during interviews (onsite or not) ?

https://leetcode.com/discuss/general-discussion/471408/Can-I-use-non-const-references-in-C%2B%2B-during-interviews-(onsite-or-not)


98. Validate Binary Search Tree

C++ 3 approaches: inorder traversal, DFS range check, BFS range check

https://leetcode.com/problems/validate-binary-search-tree/discuss/485751/c-3-approaches-inorder-traversal-dfs-range-check-bfs-range-check


69. Sqrt(x)

C++ binary search solution (two versions)

https://leetcode.com/problems/sqrtx/discuss/493465/C%2B%2B-binary-search-solution-(two-versions)


75. Sort Colors

C++ 6 approaches to solve the dutch national flag problem

https://leetcode.com/problems/sort-colors/discuss/499396/C%2B%2B-six-approaches-to-solve-the-dutch-national-flag-problem


146. LRU Cache

C++ brute force solution vs doubly linked list solution

https://leetcode.com/problems/lru-cache/discuss/500336/C%2B%2B-brute-force-solution-vs-double-linked-list-solution


37. Sudoku Solver

Why isn’t this C++ code working?

https://leetcode.com/problems/sudoku-solver/discuss/505166/Why-isn’t-this-C%2B%2B-code-working


18. 4Sum

C++ generalized to kSum

https://leetcode.com/problems/4sum/discuss/517139/C%2B%2B-generalized-to-kSum


23. Merge k Sorted Lists

C++ using priority queue

https://leetcode.com/problems/merge-k-sorted-lists/discuss/522375/C%2B%2B-using-priority-queue


25. Reverse Nodes in k-Group

C++ iterative solution & recursive solution

https://leetcode.com/problems/reverse-nodes-in-k-group/discuss/523641/C%2B%2B-iterative-solution-and-recursive-solution


127. Word Ladder

C++ fast one-end & two-end BFS

https://leetcode.com/problems/word-ladder/discuss/538333/C%2B%2B-fast-one-end-and-two-end-BFS


126. Word Ladder II

C++ two approaches

https://leetcode.com/problems/word-ladder-ii/discuss/539440/C%2B%2B-two-approaches


399. Evaluate Division

Python: weighted Union Find & BFS

https://leetcode.com/problems/evaluate-division/solutions/4688642/python-weighted-union-find-bfs/