January 10, 2022
It is time for me to make new year resolution for 2022. I plan to spend more time to work on Leetcode algorithms. I will have good time to practice algorithm, get motivated to solve more hard level algorithms.
I do think that I should stay on the track to practice more Leetcode algorithms.
Jan. 17, 2022
I came back to work on algorithm since I had to prepare for Microsoft Vancouver online assessment.
257. Binary Tree Paths
C# | Warmup | Backtracking | StringBuilder | Jan 16, 2022
1647. Minimum Deletions to Make Character Frequencies Unique
C# | Copy the idea and warm up | Keep it simple using one hashset and one array | Jan 16 2022
151. Reverse Words in a String
C# | Warmup for onsite | Define start and end char in a word | 2022 Jan 19
C# | Define start and end index of a word | C# StringBuilder Insert API | Insert the word right away
210. Course Schedule II
C# | DFS algorithm | Study Leetcode discuss C# code | Jan. 26, 2022
C# | DFS solution | Java code -> C# code | Jan. 26, 2022
874. Walking Robot Simulation
C# | Warmup algorithm and short review | 2018 Oct. 14
692. Top K Frequent Words
C# | Warmup practice | Sort once | Using simple data structure
636. Exclusive Time of Functions
C# | Opportunistic learning | Study C# code
C# | Lessons learned | My failed practice 54/120 test cases in 2020
263. Ugly Number
C# | Practice in Sept. 14, 2018
Feb. 8, 2022
1405. Longest Happy String
C# | Failed test case 24/35 | Think more carefully in design
C# | Greedy on char with largest count only | Longest is not easy
545. Boundary of Binary Tree
C# | Definition of left boundary | Reasoning behind | Feb. 2022
827. Making A Large Island
C# | Map each island using integer | Hashmap | DFS | Failed a few times
424. Longest Repeating Character Replacement
C# | Sliding window technique | mock interview
98. Validate Binary Search Tree
C# | Mock interview practice | Interviewer with MSFT, Amazon, Oracle, Meta | 2022 Feb. 23
March 4, 2022
Microsoft Vancouver onsite - Four rounds of algorithm interviews
March 2022, monthly review
March 1 - March 7
It takes self-discipline to work on Leetcode algorithms continuously. I only have less than 200 submissions last 12 months, compared to Dr. Tai, over 1500 submissions, I like to learn from him. Hard work is most important, and I should discipline myself and then I can improve my crafting skills and problem solving skills. Here is the blog with a title:
Leetcode: Jianmin Chen | Last 12 months submission | Comparison to Dr. Lai
Algorithms I worked on, 408, 1650, 1762, 314, 498, 162, 523, 282
I started to work on algorithms from votrubac, top-voted solutions: Another 11 algorithms, 1162, 1553, 992, 934, 1249, 1092, 1062, 959, 983, 1544
March 6, 2022
408. Valid Word Abbreviation
C# | learn from failed test cases
1650. Lowest Common Ancestor of a Binary Tree III
C# | Space complexity O(1)
1762. Buildings With an Ocean View
C# | Using stack
314. Binary Tree Vertical Order Traversal
C# | Preorder traversal | Record total count, horizontal, level in the tree
March 7, 2022
498. Diagonal Traverse
C# | Automatically direction change
162. Find Peak Element
C# | Binary search algorithm
523. Continuous Subarray Sum
C# | Learn from failed test cases
March 5, 2022
Algorithm to plan to work on
I chose to work on Leetcode with tag Facebook, last six month most frequent algorithms.
Algorithm 314, 1762, 1570, 1650, 528, 408, 339, 71, 31, 670;
10 more: 498, 162, 523, 282, 1891, 1011, 708, 1382, 1539, 2060;
10 more: 266, 286, 1868, 1216, 348, 778, 536, 270, 1428, 825;
10 more: 269, 658, 16, 2056, 43, 1060, 380, 1344, 1522, 1944;
10 more: 1644, 2076, 689, 1424, 983, 224, 298, 742, 767, 333;
10 more: 2019, 2033, 238, 1541, 1209, 2071, 296, 1244, 2065, 2081;
10 more: 406, 271, 1498, 735, 163, 1245, 1559, 247, 2025, 1197;
723, 2092, 62, 540, 1985
work hard | Hard work beats talent
Do not think too much. Just work on more algorithms. Solve as many algorithms as I can. Once I solve another 20 algorithms, stop and review what I have learned, and then continue to solve another 20 algorithms.
Here is my blog written on March 5, 2022. Good planning is important for success for any project.
March 8, 2022
282. Expression Add Operators (Hard level)
C# | Excellent learning opportunity
C# | Learning opportunities
March 10, 2022
862. Shortest Subarray with Sum at Least K
C# | Design a deque | Review Array - Subarray | 2022 March
March 16, 2022
39. Combination Sum
C# | Warmup practice | DFS | Backtracking | 2022
128. Longest Consecutive Sequence
C# | Time complexity: O(N) | Python code converted to C#
C# | Time complexity: O(N), N is length of the array
Leetcode 78 subsets, 90 Subset II, 77 combinations, 40 Combinations Sum II, 377 Combination Sum IV
Plan to type those python code from Li Yin's book, and then convert those code into C# code.
March 17, 2022
15. 3Sum
C# | Time complexity: O(N^2) | Review code written in 2016
C# | Warmup in 2022 | Using HashSet to remove duplicate
C# | Time complexity O(N^2) | Remove duplicate by sorting, no use of HashSet
C# | Time complexity O(N^2) | Use HashSet
18. 4Sum
C# | Sorting, sliding window, skip duplicate | Time: O(N^3)
454. 4Sum II
C# | Optimal time complexity: O(N^2), not O(N^3)
March 21, 2022
2096. Step-By-Step Directions From a Binary Tree Node to Another
C# | Preorder | TLE error 287/332
The above practice shows that I have weakness in terms of design recursive function, use post order traversal or preorder, TLE issue.
C# | Post order | Study discuss post | Solve TLE problem
C# | Post order traversal | Solve TLE problem
I practice near 10 algorithms last weekend, and I chose to study discussion post written by votrubac top-voted discuss posts.
I found so many issues and learned how to solve a few more algorithms related to DP, tree and graph problems.
March 21, 2022
1162. As Far from Land as Possible
C# | BFS | All land nodes into Queue | Search together
1553. Minimum Number of Days to Eat N Oranges
C# | Understand the subproblems
992. Subarrays with K Different Integers
C# | At most K | Two subproblems -> difference
934. Shortest Bridge
C# | Apply DFS to visit all nodes in each island | Brute force two nodes' distance
1249. Minimum Remove to Make Valid Parentheses
C# | Using stack | * to replace unmatched parentheses
1092. Shortest Common Supersequence
C# | LCS DP solution first | Learn C# code
1062. Longest Repeating Substring
C# | DP solution | Time complexity: O(N^2)
959. Regions Cut By Slashes
C# | DFS | Understand the problem
983. Minimum Cost For Tickets
C# | DP solution | learn 20 algorithms from one player
1524. Number of Sub-arrays With Odd Sum
C# | New idea to find algorithm to work on | Solutions tag
March 22, 2022
1675. Minimize Deviation in Array
C# | Learn the analysis first | Learn C# code
1039. Minimum Score Triangulation of Polygon
C# | DP solution | Brute force | Bottom up, how to define bottom subproblem?
March 31, 2022
1466. Reorder Routes to Make All Paths Lead to the City Zero
C# | Graph problem | Quick study | Warmup
1320. Minimum Distance to Type a Word Using Two Fingers
C# | DP solution | Need more time
April 1, 2022
1371. Find the Longest Substring Containing Vowels in Even Counts
C# | "aeiou" -> one integer, 5 bits, 32 variations | Warmup for Meta onsite
1721. Swapping Nodes in a Linked List
C# | One pass | Kth node and kth to Last | Secret - one follower starts kth node
Leetcode discuss
30 days to Meta onsite | 4th Facebook onsite | System design | Daily update - Day 1
April 18, 2022
36. Valid Sudoku
C# | Validation process | HashSet
C# | Encode string - three ideas to map same row, same column, same 3 x 3 matrix
April 19, 2022
80. Remove Duplicates from Sorted Array II
C# | Quick study and prepare for Meta onsite
May 26, 2022
I solved another 35 algorithms from April 18 to May 16, 2022.
I got an email notification about Meta onsite cancellation. My onsite interview scheduled on May 16, 2022 was cancelled because of hiring freeze.
I will take 30 minutes to add those algorithms one by one in the following:
Container With Most Water
Find Median from Data Stream
Wiggle Sort II
Palindrome Linked List
Poor Pigs
Binary Watch
Number of Matching Subsequences
Game of Life
Find K Pairs with Smallest Sums
Number of Digit One
Verify Preorder Sequence in Binary Search Tree
Queue Reconstruction by Height
Flip String to Monotone Increasing
String Without AAA or BBB
Longest Common Prefix
Count Vowel Substrings of a String
Min Cost to Connect All Points
Number of Wonderful Substrings
The k Strongest Values in an Array
Sum of Subarray Minimums
Maximum Sum of Two Non-Overlapping Subarrays
Largest Multiple of Three
Maximum Distance Between a Pair of Values
Maximum Number of Consecutive Values You Can Make
Rank Transform of a Matrix
May 19, 2022
1632. Rank Transform of a Matrix
C# | Quick learner | Union find algorithm | Illustration using diagrams
1798. Maximum Number of Consecutive Values You Can Make
C# | Quick learner | I tried 10 minutes to figure out something first
May 17, 2022
1855. Maximum Distance Between a Pair of Values
C# | Two sorted arrays | Two pointer technique | Linear time complexity
1363. Largest Multiple of Three
C# | Quick learner | At most remove two digits
1031. Maximum Sum of Two Non-Overlapping Subarrays
C# | Quick learner | 30 minutes to study
May 12, 2022
907. Sum of Subarray Minimums
C# | Quick learner | Using stack O(N) time complexity | Play for fun
1471. The k Strongest Values in an Array
C# | Quick learner | two pointers
May 5, 2022
1915. Number of Wonderful Substrings
C# | Quick learner | 10 bits to represent a - j count as odd or even
1584. Min Cost to Connect All Points
C# | Quick learner | Union find algorithm
May 4, 2022
2062. Count Vowel Substrings of a String
C# | Quick learner | Sliding window
May 3, 2022
984. String Without AAA or BBB
C# | Quick learner | greedy idea
406. Queue Reconstruction by Height
C# | Quick learner from an example
May 2, 2022
255. Verify Preorder Sequence in Binary Search Tree
C# | 15 minutes as a quick learner | Recursive solution
233. Number of Digit One
C# | 30 minutes to work on hard level
373. Find K Pairs with Smallest Sums
C# | Minimum heap | SortedSet<Tuple<int, int, int> | Two neighbors: right and bottom
289. Game of Life
C# | in-place algorithm using module 10
792. Number of Matching Subsequences
C# | Group words by starting char | Avoid TLE error
401. Binary Watch
C# | Bit manipulation | DFS algorithm
April 26, 2022
458. Poor Pigs
C# | Hard level | One pig can test multiple buckets a time
April 25, 2022
234. Palindrome Linked List
C# | Optimal solution O(N) time complexity O(1) space
C# | Review of my practice in July 2018
324. Wiggle Sort II
C# | Using Sorting to find median value
April 22, 2022
295. Find Median from Data Stream
C# | Minimum heap and maximum heap | SortedSet<Tuple<int, int>>
April 19, 2022
11. Container With Most Water
C# | Two pointers technique | Time complexity: O(N)
June 8, 2022
I came cross this algorithm when I read Leetcode interview discuss panel. I could not understand my own discuss post, so I quickly added one test case, and then added more detail for me to understand the algorithm.
204. Count Primes
C# as simple as possible
June 13 - 14, 2022
I spent a lot of hours to learn how to write union find algorithms in 2019. Here is the link. After a few years, I think that it is better for me to write something on Leetcode, so I can share my experience with more people.
947. Most Stones Removed with Same Row or Column
C# | Quick learner | Union find | DFS | 8 solutions
C# | Quick learner | Union find with rank and size | Ranking No 40
C# | Quick learn | Union find with rank | Rank No 176
C# | Quick learner | Union find API | Rank 8
C# | Quick learner | DFS | Rank 5
C# | Quick learner | DFS | Rank 16
C# | Quick learner | Union find | Rank 12
C# | Quick learner | Union Find | Find Parent API getRoot | Rank 117
C# | Quick learner | Union Find | With Rank | Player No. 13
June 21, 2022
1284. Minimum Number of Flips to Convert Binary Matrix to Zero Matrix
C# | Quick learner | BFS | Matrix -> 9 bit integer at most
C# | Quick learner | BFS | Encoding -> "abcdefghi"
June 22, 2022
428. Serialize and Deserialize N-ary Tree
C# | Quick learner | DFS | Add a test case | Ideas -> design -> C# code -> design
June 23, 2022
1096. Brace Expansion II | Hard level
C# | Quick learner | First solution - still working on
June 23, 2022
224. Basic Calculator | Hard level
C# | Quick learner | Stack | Design talk
772. Basic Calculator III | Hard level
C# | Quick learner | High precedence | Recursive
June 28, 2022
847. Shortest Path Visiting All Nodes | Hard level
C# | Quick learner | BFS | How to define a state?
June 29, 2022
I plan to work on the following hard level algorithms in next two weeks:
1597, 2158, 296, 1948, 778, 632, 302, 272, 753, 1240, 425, 410, 1793, 1235, 920, 365
465. Optimal Account Balancing | Hard level
C# | Quick learner | DFS, backtracking, GraceMeng top voted
July 18, 2022
1104. Path In Zigzag Labelled Binary Tree
C# | Quick learner | Show progress
C# | Quick learner | Apply math analysis
C# | Quick learner | 10 minutes a solution
I work on discuss post with downvote - 84 largest rectangle in histogram. What I did is to add a solution using stack before a brute force solution.
July 19, 2022
84. Largest Rectangle in Histogram
C# | Quick learner | Optimal time complexity solution provided
737. Sentence Similarity II
C# | Quick learner | Union find algorithm