Skip to content

Latest commit

 

History

History
398 lines (318 loc) · 40.3 KB

2019AlgorithmPractice.md

File metadata and controls

398 lines (318 loc) · 40.3 KB

Try again. Fail again. Fail better.
I always like to use this quote to remind me to stay humble, and continue to push myself to practice one more algorithm every day.
“Ever tried. Ever failed. No matter. Try again. Fail again. Fail better.” The “Fail Better” Quote by Samuel Beckett

I like to list all algorithms I practice in 2019. I need to constantly find new algorithms to work on, and also review my past practice as well.

I can easily find out what algorithms I solve by looking up my github page and sorting by the date time. Here is the folder to contain images of all algorithms I save in Leetcode source code folder.

2018

August 2018
283. Move Zeroes C# go ahead to work on nonzero numbers

2018 - November
222. Count Complete Tree Nodes C# optimal time complexity O(h * h), h is the height of tree (3 upvotes!)

Nov. 24, 2018
894. All Possible Full Binary Trees C# Similar to two sum problem

2018 - December
958. Check Completeness of a Binary Tree Learn from a casual coder
958. Check Completeness of a Binary Tree C# preorder traversal and play with use case related to leaf nodes
2019 - January
37. Sudoku solver Another elegant solution learned from a casual coder
145. Binary Tree Postorder Traversal My practice, using hashset to mark visited
145. Binary Tree Postorder Traversal idea I learned as interviewer
145. Binary Tree Postorder Traversal idea I learned from Taras comment from a casual coder blog

2019
2019 - February
Feb. 2
987. Vertical Order Traversal of a Binary Tree study code from a casual coder
987. Vertical Order Traversal of a Binary Tree C# leetcode online judge for C# test case is problematic
996. Number of squareful arrays
996. Number of squareful arrays Learn from a casual coder, 3 upvotes(May 1, 2019)

2019 - March
March 21, 2019
1012. Numbers With Repeated Digits C# Study code from ranking No. 1 in weekly contest 128 (4 upvotes up to Oct. 8, 2019)
1012. Numbers With Repeated Digits C# standard depth first search with back tracking (1 upvotes up to Oct. 8, 2019)

2019 - April
4/29
1035. Uncrossed Lines C# dynamic programming solution readable code
1034. Coloring A Border C# using two negative values to mark visited, -1 for the mark to change color
1033. Moving Stones Until Consecutive Ever tried. Ever failed. No matter. Try again
4/23
957. Prison Cells After N Days C# First practice in April 2019
4/22/2019
75. Sort Colors C# Work on test case [2, 0, 1, 2] and then figure out the idea
1031. Maximum Sum of Two Non-Overlapping Subarrays Need to shorten the time
402. Remove K Digits C# easy to write using stack with analysis
402. Remove K Digits C# brute force solution - time consuming and struggling
4/15
1026. Maximum Difference Between Node and Ancestor code written in weekly contest
1025. Divisor Game C# recursive function practice after the weekly contest
1025. Divisor Game dynamic programming solution - Attention Please!
4/10
1024. Video Stitching C# greedy algorithm only one iteration on sorted array
4/18
1023. Camelcase Matching written in the contest 131
1023. Camelcase Matching solution learned after the contest
1022. Sum of Root To Leaf Binary Numbers C# a recursive function with module calculation
1021. Remove Outermost Parentheses
4/2
947. Most Stones Removed with Same Row or Column C# Use partial of union find algorithm to solve the problem
947. Most Stones Removed with Same Row or Column C# apply depth first search in a graph
947. Most Stones Removed with Same Row or Column weekly contest ranking 5, 8, 12, 13, 16, 40, 58, 117, 176 players - code study
947. Most Stones Removed with Same Row or Column union find algorithm study - rank, size, path compression, common mistakes, while/ recursive implementation
200. Number of Islands C# depth first search practice

2019 - May

May 11
10. Regular Expression Matching C# one practice brought me back sweet story of practice in 2018
399. Evaluate Division Ask advice from the author - Amazon Senior SDE
399. Evaluate Division learn from C# code written in 2017
399. Evaluate Division Case study: C# expert and algorithm good problem solver
785 Is graph bipartite union find algorithm
785 Is graph bipartite depth first search algorithm
91. Decode Ways Code written in 2019
1037. Valid Boomerang 34 minutes for an easy algorithm
1038. Binary Search Tree to Greater Sum Tree how two small mistakes drag down my performance from 10 minutes to 50 minutes
1042. Flower Planting With No Adjacent code written in weekly contest
May 6 - 11
235. Lowest Common Ancestor of a Binary Tree binary search in BST
236. Lowest Common Ancestor of a Binary Search Tree time out using string, need help
236. Lowest Common Ancestor of a Binary Search Tree time out using list, need help
236. Lowest Common Ancestor of a Binary Search Tree optimal solution bottom up with reasoning
236. Lowest Common Ancestor of a Binary Search Tree various topics covered through 2019 practice
June 10, 2019
236. Lowest Common Ancestor of a Binary Search Tree C# Recursive function design to return Stack practice in 2019

May 14
146. LRU Cache May 2019 pass 12/ 18 test cases
May 24
329. Longest Increasing Path in a Matrix C# depth first search and memoization classical algorithm
May 27
241 Different Ways To Add Parentheses practice in 2019 May - a Google interview algorithm
124. Binary Tree Maximum Path Sum 2019 May practice
1037. Valid Boomerang 34 minutes for an easy algorithm

459. Repeated Substring Pattern C# readable code with some pruning ideas

2019 - June
June 3
987. Vertical Order Traversal of a Binary Tree study code from a casual coder
1073. Adding Two Negabinary Numbers C# so many trial and error in my first practice
1073. Adding Two Negabinary Numbers Use stack to remove leading zero
1073. Adding Two Negabinary Numbers learn to use next two bit to carry
1071. Greatest Common Divisor of Strings brute force solution missed in weekly contest
1074. Number of Submatrices That Sum to Target write code first and then figure out what is the idea
June 4, 2019
687. Longest Univalue Path various topics covered in practice from 2018 to 2019

687. Longest Univalue Path C# brute force on every node for cross path with detail explanation practice in 2019

June 8 - 10
1079. Letter Tile Possibilities C# various topics covered in my practice in 2019
1079. Letter Tile Possibilities C# learn to write a solution after the weekly contest on June 8, 2019
1079. Letter Tile Possibilities C# counting sort and depth first search to count unique substrings practice in 2019
1079. Letter Tile Possibilities C# case study "AAB" to figure out the solution in 2019
1081. Smallest Subsequence of Distinct Characters C# using stack and also counting sort
1080. Insufficient Nodes in Root to Leaf Paths C# code could not pass large test case in weekly contest
1078. Occurrences After Bigram C# One iteration of parsed words
June 10, 2019
236. Lowest Common Ancestor of a Binary Search Tree C# Recursive function design to return Stack practice in 2019
June 17, 2019
1091. Shortest Path in Binary Matrix C# breadth first search practice in 2019
1090. Largest Values From Labels C# Try to solve using greedy algorithm practice in 2019
1089. Duplicate Zeros C# trial and error practice in weekly contest 141

June 12 - 18
377. Combination Sum IV
C# various topics in my practice 2019
Recursive solution with timeout issue, here is the link.
Dynamic programming, top down, memoization, here is the link.
Dynamic programming, bottom up, here is the link.

  1. Shortest Path in Binary Matrix
    C# breadth first search practice in 2019
    Here is the link.

  2. Largest Values From Labels
    C# Try to solve using greedy algorithm practice in 2019

June 22 - 24
518. Coin Change 2 C# First practice with timeout issue in 2019
518. Coin Change 2 First practice in 2019
518. Coin Change 2 All practices in 2019
78. Subsets C# backtracking pattern algorithm review in 2019
39. Combination Sum C# backtracking DFS practice in 2018
39. Combination Sum C# DFS practice in 2017
210. Course Schedule II C# first practice back in February 2017
More patience on problem solving - 210. Course Schedule II Review my practice Algorithm 210.

Review 684 Redundant connection
684. Redundant Connection C# solution using union find algorithm implemented using array Aug 11 2018
684. Redundant Connection C# solution using disjoint set algorithm to solve using Dictionary<Int, HashSet>

June 26, 2019
I wrote my experience on this topic: Consistent practice advice
My writing is here.

June 27, 2019
402. Remove K Digits
C# Ideas I practice in 2019
C# slide window and bucket sort practice in 2019

July 2, 2019
42. Trapping Rain Water
C# First success submission back in May 2018

56 Merge intervals
C# First practice using LINQ in Feb 2017
C# IComparer class definition practice in February 2017
C# various practice in 2019

  1. Word Ladder II
    Time limit exceeded practice in 2019

  2. Word Ladder

C# BFS practice in 2019
C# BFS practice back I in June 2016
C# BFS practice back II in June 2016

  1. Next Greater Element III
    C# using stack practice in August 2018

  2. Find Duplicate Subtrees
    C# post order traversal and use serialized string to help Problems found in my first practice in Dec. 2018

July 3, 2019
97. Interleaving String
C# dynamic programming practice in August, 2018

July 4, 2019
I went over discuss on Leetcode.com, and then had chance to review my past practice; I quickly wrote posts to share my past practice as well.
88. Merge Sorted Array

C# first practice back in August 2018

212 Word search II

C# First practice using Trie in 2017

C# practice using Trie and good explanation in detail
C# Using Trie with a case study practice in January 2018

  1. Insert Interval
    C# First practice in 2017
    C# Sort intervals using start time first practice in 2017

  2. Implement strStr()

C# KMP algorithm practice in 2015

  1. Word Break
    C# Dynamic programming practice in 2016 First time to share my practice in 2016

July 5, 2019
140. Word Break II (Hard level)
C# DFS with memoization practice in July 2019
C# First practice in June 2018

July 15, 2019
76. Minimum Window SubstringC# slide window template study code practice in 2019

July 16, 2019
67. Add Binary
C# a while loop to practice in 2019
C# Write a simple for loop practice in 2019

  1. Validate Binary Search Tree

C# post order traversal practice in 2019
C# preorder traversal and warmup stack practice in 2019
C# preorder traversal practice in 2019
C# preorder traversal and previous node's val practice in 2019

  1. Sliding Window Median
    C# using List.BinarySearch API practice in 2019

July 18, 2019

  1. Maximum Gap
    C# My first practice in 2018

  2. Edit distance
    C# My practice history - dynamic programming

  3. Partition Equal Subset Sum
    C# dynamic programming practice in 2019
    C# Knapsack problems review in July 2019
    C# depth first search and pruning practice in 2019 (July 7, 2019)

August 17, 2019
214. Shortest Palindrome
C# Learn how to construct long prefix suffix table practice in 2019

August 19, 2019
109 Convert sorted list to binary search tree
C# - Inorder traversal idea with iterating the linked list node one by one

August 22, 2019
33. Search in Rotated Sorted Array
C# modified binary search practice on August 22, 2019

August 23, 2019
Various ideas to practice in 2019. Here is the link.
Time Line: 2019 August 20 Onsite interview, whiteboard version with bugs on August 20, 2019, California, MPK, here is the link.

Time Line: 2019 August 22 Optimal solution, avoid middle - 1 or middle + 1, practice on August 22, 2019. Here is the link.

Time Line: 2019 August 23 Work on idea to define left half [start, middle - 1], practice on August 23, 2019. here is the link. Time Line: 2017 My practice in 2017. Here is the link.

Time Line: 2017 Common mistakes in binary search is my favorite research topic in 2017. Here is the blog.

My mock interview practice in 2017, here is the blog with source code link in the blog as well.

126. Word Ladder II

C# Time limit exceeded practice in 2019
Sept. 12, 2019
C# creative idea to create a graph and then construct shortest path map practice in 2019

simple version:
Find all paths from given start word and end word, also a dictionary of words to connect, one char to change every step.

Brute force solution - using DFS - Sept. 2019

Sept 21, 2019
1200. Minimum Absolute Difference
C# Sort the array and then find the minimum

Sept. 23, 2019
1202. Smallest String With Swaps

C# union find algorithm practice in 2019
C# union find algorithm warmup practice in 2019


Sept. 23, 2019
1202. Smallest String With Swaps C# union find algorithm practice in 2019
Sept. 24, 2019
1202. Smallest String With Swaps C# union find algorithm warmup practice in 2019

Sept. 26, 2019
1110. Delete Nodes And Return Forest C# preorder traversal practice in 2019
Sept. 30, 2019
1207. Unique Number of Occurrences C# Use hash map and hash set to solve the problem
1208. Get Equal Substrings Within Budget C# sliding window to achieve linear time complexity practice in 2019

October 2019
Oct. 5, 2019
1218. Longest Arithmetic Subsequence of Given Difference C# dynamic programming solution practice in 2019
Oct. 11, 2019
637. Average of Levels in Binary Tree C# BFS search starting from root node practice in 2019
966. Vowel Spellchecker C# timeout issue are so rewarding in my practice in 2019
Oct. 12, 2019
1222. Queens That Can Attack the King C# Loop on each direction starting from king position practice
1221. Split a String in Balanced Strings C# count 'L' as -1 and 'R' as +1

Review two practice back in 2017
I found the blog written in May 2016, just one month before my first Amazon onsite interview in the city of Vancouver. I was shy at that time, I used to talk to myself, Julia should be "I". I learn the way to describe myself using she/ her/ Julia. So sweet to read the blog written in 2016. Sweet memory.
48. Rotate image is the blog.
48. Rotate Image C# Apply some matrix technique practice in 2017
48. Rotate Image C# First practice - straightforward solution in 2017

Review 54 Spiral matrix
54 Spiral matrix
54 Spiral matrix My first practice back in 2015
54 Spiral matrix a few ideas to expedite the problem solving
54 Spiral matrix optimal space - direction array

Oct 19 - Oct. 21
1234. Replace the Substring for Balanced String
1234. Replace the Substring for Balanced String C# sliding window technique - extra time needed
1234. Replace the Substring for Balanced String C# Code study: a solution can be written in two loops
1234. Replace the Substring for Balanced String C# code study: Weekly contest 159 ranking No. 1 - binary search

Oct. 21 - Oct. 25, 2019
1170. Compare Strings by Frequency of the Smallest Character C# Sort first and then get count of smallest character
985. Sum of Even Numbers After Queries C# Using dynamic programming to track sum of even numbers
1128. Number of Equivalent Domino Pairs C# Learn from three failed test cases
999. Available Captures for Rook C# work on directions and also boundary check carefully
1122. Relative Sort Array C# Good learning experience
509. Fibonacci Number C# optimal time and space complexity
1160. Find Words That Can Be Formed by Characters C# Counting sort technique
1051. Height Checker C# Solve 60 easy level algorithms - No 1 of 60

Oct. 29, 2019
1238. Circular Permutation in Binary Representation Design algorithm using DFS similar to Sudoku solver
989. Add to Array-Form of Integer C# Learn IEnumerable Skip and Take API
989. Add to Array-Form of Integer C# iterative solution
1239. Maximum Length of a Concatenated String with Unique Characters C# A solution with readable code using DFS

Oct. 31, 2019
475. Heaters C# binary search to avoid timeout issue

Nov. 2, 2019
1248. Count Number of Nice Subarrays C# - preprocess the array first
1247. Minimum Swaps to Make Strings Equal C# learn from two test cases

Nov. 5, 2019
70. Climbing Stairs C# dynamic programming using O(1) space
1189. Maximum Number of Balloons C# count chars in "ablon" and then calculate minimum value by a factor

Nov., 12, 2019
1103. Distribute Candies to People C# Work on basics - while loop

Nov. 14, 2019
884. Uncommon Words from Two Sentences C# Fail three times to succeed
299. Bulls and Cows C# digit count and comparison count of same digit same position

Nov. 24, 2019
239. Sliding Window Maximum C# mock interview performance with code review in 2019
117. Populating Next Right Pointers in Each Node II C# using level by level traversal practice in 2019
69. Sqrt(x) C# binary search practice with challenges in 2019

Nov. 24, 2019
124. Binary Tree Maximum Path Sum C# mock interview practice on Nov 24, 2019
207. Course Schedule C# mock interview practice on Nov. 24, 2019
210. Course Schedule II C# mock interview practice on Nov 24, 2019