GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com โ€” GitHub - hereisderek/code_practice: coding practice, mostly on leetcode

BranchesTags
Open more actions menu

Latest commit

 

History

47 Commits
47 Commits

Folders and files

NameName
Last commit message
Last commit date
.idea
.idea
 
 
gradle/wrapper
gradle/wrapper
 
 
src
src
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
build.gradle.kts
build.gradle.kts
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle.kts
settings.gradle.kts
 
 

Repository files navigation

Code practice link


Templates

Difficulty Marks Name link Notes
๐ŸŸข โœ…โ—โ“โŒ Leetcode
๐ŸŸ  โœ…โ—โ“โŒ Leetcode
๐Ÿ”ด โœ…โ—โ“โŒ Leetcode

Markers:

  • โœ…/โœ”๏ธ For finished
  • ๐Ÿ‘ท For working in progress
  • โŒ For unfinished due to complicity or challenging
  • โ—For marking good questions
  • โ“with doubt or unfinished
  • Strikedthrough For not bothering (e.g. too easy)
  • MARK in code for paying extra attention

Difficulties:

  • ๐ŸŸข(Easy)
  • ๐ŸŸ (Medium)
  • ๐Ÿ”ด(Hard) ๐Ÿคจ

Kotlin

Since I use kotlin, I have created some convenient utility functions, mostly for testing/debugging purpose. (I might just create a branch with just the utility functions, however.. )

Note: To enable assertion for kotlin, pass in -ea as jvm launch argument, see this link

Other than those listed below, check out _util.kt for more

  1. Run timed tests on a list of method variable. Sample usage checkout this Update: I noticed that this method may not be accurate, not sure of the cause
@OptIn(ExperimentalTime::class)
inline fun<reified T : KCallable<*>, reified R> List<T>.runTimedTests(
    testName: String? = Thread.currentThread().stackTrace.getOrNull(1)?.className?.split("$", limit = 0)?.get(0),
    printTime: Boolean = true,
    block: T.()->R
) {
    forEachIndexed { index, it ->
        val timeValue = measureTimedValue{ it.block() }
        val prefix = if (testName.isNullOrEmpty()) "" else "${testName}."
        if (printTime) println("execution for ${prefix}${it.name} finished, took ${timeValue.duration.inWholeNanoseconds} Nanoseconds")
    }
}

Sample print out:

execution for _2022._05.Leetcode_15.MY1.threeSum finished, took 476348 Nanoseconds
execution for _2022._05.Leetcode_15.MY1.threeSum finished, took 423606 Nanoseconds
execution for _2022._05.Leetcode_15.MY2.threeSum finished, took 435733 Nanoseconds
  1. Assertion (assertEqual)
test() assertEqual "expected" // for single answer
test().assertEqual("possible_output1", "possible_output2") // for multiple correct answers 
  1. Build-in data types
    1. Node (typealias IntNode = Node<Int>) and some built-in functions, e.g:
      1. fun <T> linkedNodesOf(vararg nodes: T) : Node<T> usage:linkedNodesOf(1, 2, 3) to create a linked nodes like 1 -> 2 -> 3
      2. fun <T> Node<T>.toList() : List<T> usage: linkedNodesOf(1, 2, 3).toList() gets: [1,2,3]
      3. fun <T, R> Node<T>.mapValue(transform: ((T)->R)) : List<R> usage: linkedNodesOf(1, 2, 3).mapValue{ it * 2 } gets [2,4,6]
      4. others see this file: Node

202205

20220528

youngyangyang04/leetcode-master/0001.ไธคๆ•ฐไน‹ๅ’Œ.md ยท GitHub

Marks link Notes
๐ŸŸขโœ… 1. Two Sum
๐ŸŸขโœ… 342. Valid Anagram
๐ŸŸขโœ… 349. Intersection of Two Arrays
๐ŸŸข 383. Ransom Note
๐ŸŸขโœ… 49. Group Anagrams

20220529, 20220601

youngyangyang04/leetcode-master/0005.ๆœ€้•ฟๅ›žๆ–‡ๅญไธฒ.md ยท GitHub

Marks link Notes
๐ŸŸ โœ… 647. Palindromic Substrings
๐ŸŸ โ—โ“ 5. Longest Palindromic Substring

20220602, 20220605, 20220606

youngyangyang04/leetcode-master/0005.ๆœ€้•ฟๅ›žๆ–‡ๅญไธฒ.md ยท GitHub

Difficulty Marks link Notes
Medium โœ…โ— 5. Longest Palindromic Substring [leetcode] [git]
Medium โœ… 15. 3Sum ๐Ÿ’ƒ๐Ÿ’ƒ๐Ÿ’ƒ [leetcode] [git] My4 not done

20220606

Difficulty Marks Name link Notes
Easy ๐ŸŸ โœ…
Medium ๐ŸŸขโœ… 17. Letter Combinations of a Phone Number Leetcode Github Didn't read the sample code since it didn't take me too much thinking to solve the question, but it might worth a read
Medium Skipped for now 18. 4Sum ๐Ÿ’ƒ๐Ÿ’ƒ๐Ÿ’ƒ๐Ÿ’ƒ Leetcode Github
Medium ๐ŸŸ โ“ 19. Remove Nth Node From End of List Leetcode Github

20220607 labuladong

Difficulty Marks Name link Notes
Easy ๐ŸŸขโœ… 21. Merge Two Sorted Lists Leetcode labuladong Sample1 is interesting (recursion)
Easy ๐ŸŸขโœ… 141. Linked List Cycle Leetcode
Medium โ— 142. Linked List Cycle II Leetcode labuladong

20220608,20220614 labuladong

Difficulty Marks Name link Notes
Hard ๐ŸŸขโœ… 23. Merge k Sorted Lists Leetcode labuladong Need to read the sample code
Easy โ— 160. Intersection of Two Linked Lists Leetcode labuladong Sample1 is interesting (recursion)

20220614,20220615

labuladong

Difficulty Marks Name link Notes
Easy ๐ŸŸข 876. Middle of the Linked List Leetcode Faster than 100% submission ๐ŸŸข๐ŸŸข
Medium โ— 92. Reverse Linked List II Leetcode My2
Easy ๐ŸŸ โœ… 206. Reverse Linked List Leetcode Need to check sample and read this and read S1

20220615,20220615

Difficulty Marks Name link Notes
Hard ๐Ÿ”ดโ—โ—โ“ 25. Reverse Nodes in k-Group Leetcode

TODO:

  • https://labuladong.github.io/algo/2/17/18/

20220616

Difficulty Marks Name link Notes
๐ŸŸข โŒ 234. Palindrome Linked List Leetcode
๐ŸŸข โœ… 26. Remove Duplicates from Sorted Array Leetcode
๐ŸŸข โœ… 27. Remove Element Leetcode
๐ŸŸข โœ… 83. Remove Duplicates from Sorted List Leetcode

TODO: Leetcode_710


20220617

Difficulty Marks Name link Notes
๐ŸŸ  โœ…๐ŸŸข 167. Two Sum II - Input Array Is Sorted Leetcode
๐ŸŸข โœ… 283. Move Zeroes Leetcode

20220618

Difficulty Marks Name link Notes
๐ŸŸข โœ… 344. Reverse String Leetcode
๐ŸŸข โœ… 303. Range Sum Query - Immutable Leetcode
๐ŸŸ  โœ… 304. Range Sum Query 2D - Immutable Leetcode

Leetcode 370: Range Addition


20220619

Difficulty Marks Name link Notes
๐ŸŸ  โ“ 370: Range Addition Leetcode Put off for now
๐ŸŸ  โœ…๐ŸŸข 1094. Car Pooling Leetcode
๐ŸŸ  โ“ 1109. Corporate Flight Bookings Leetcode
๐ŸŸ  โ“ 48. Rotate Image Leetcode

20220620

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 54. Spiral Matrix Leetcode

20220621

Difficulty Marks Name link Notes
๐ŸŸ  โ“ 59. Spiral Matrix II Leetcode
๐ŸŸ  โœ…โ“ 3. Longest Substring Without Repeating Characters Leetcode TODO: read explanation

20220627,20200630

Difficulty Marks Name link Notes
๐Ÿ”ด 76. Minimum Window Substring Leetcode
๐ŸŸ  34. Find First and Last Position of Element in Sorted Array Leetcode
๐ŸŸ  1109. Corporate Flight Bookings Leetcode

20220701

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 11. Container With Most Water Leetcode
๐Ÿ”ด โœ…โ—โ“โŒ 42. Trapping Rain Water Leetcode

20220702

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 238. Product of Array Except Self Leetcode
๐ŸŸข โœ… 217. Contains Duplicate Leetcode
๐ŸŸ  โœ… 347. Top K Frequent Elements Leetcode 1. Heatmap, 2. bucket list/sort
๐ŸŸข โœ… 125. Valid Palindrome Leetcode
๐ŸŸ  โœ… 271. Encode and Decode Strings Lintcode_659

20220703

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 128. Longest Consecutive Sequence Leetcode
๐ŸŸข โœ… 121. Best Time to Buy and Sell Stock Leetcode
๐ŸŸ  โœ…โ“ 424. Longest Repeating Character Replacement Leetcode
๐ŸŸ  โœ… 567. Permutation in String Leetcode

20220704

Difficulty Marks Name link Notes
๐Ÿ”ด โœ…โ—โ“โŒ 239. Sliding Window Maximum Leetcode
๐ŸŸข โœ… 20. Valid Parentheses Leetcode
๐ŸŸ  โœ…โ— 155. Min Stack Leetcode The use of miniStack in S1 and S2

20220705

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 150. Evaluate Reverse Polish Notation Leetcode
๐ŸŸ  โœ…โ“ 22. Generate Parentheses Leetcode
๐ŸŸข โœ…โ—โ“โŒ 496. Next Greater Element I Leetcode

20220724

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 739. Daily Temperatures Leetcode
๐ŸŸ  โœ… 853. Car Fleet Leetcode
                                        |            |

20220725

Difficulty Marks Name link Notes
๐Ÿ”ด โŒ 84. Largest Rectangle in Histogram Leetcode
๐ŸŸข โœ… 704. Binary Search Leetcode
๐ŸŸ  โœ… 74. Search a 2D Matrix Leetcode
๐ŸŸ  โœ…โ— 875. Koko Eating Bananas Leetcode
๐ŸŸ  โŒ 33. Search in Rotated Sorted Array Leetcode
๐ŸŸข โœ…โ—โ“โŒ Leetcode
๐ŸŸ  โœ…โ—โ“โŒ Leetcode
๐Ÿ”ด โœ…โ—โ“โŒ Leetcode

20220726

Difficulty Marks Name link Notes
๐ŸŸ  โœ…โ—โ“โŒ 143. Reorder List Leetcode
๐ŸŸข โœ…โ—โ“โŒ Leetcode
๐ŸŸ  โœ…โ—โ“โŒ Leetcode
๐Ÿ”ด โœ…โ—โ“โŒ Leetcode

20220727

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 138. Copy List with Random Pointer Leetcode

2022078

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 2. Add Two Numbers Leetcode
๐ŸŸ  โŒ 287. Find the Duplicate Number Leetcode
๐ŸŸ  โŒ 146. LRU Cache Leetcode

20220729

Difficulty Marks Name link Notes
๐ŸŸข โœ… 226. Invert Binary Tree Leetcode
๐ŸŸข โœ…โ— 104. Maximum Depth of Binary Tree Leetcode
๐ŸŸข โœ… 110. Balanced Binary Tree Leetcode
๐ŸŸข โœ… 100. Same Tree Leetcode
๐ŸŸข โœ…โ— 572. Subtree of Another Tree Leetcode
  • 572: can use a utility method isSameTree to check or need to be careful (see solution)

20220730

Difficulty Marks Name link Notes
๐ŸŸข โœ… 235. Lowest Common Ancestor of a Binary Search Tree Leetcode
๐ŸŸข โœ…โ—โ“โŒ 703. Kth Largest Element in a Stream Leetcode
๐ŸŸข โœ… 1046. Last Stone Weight Leetcode
๐ŸŸข โœ… 70. Climbing Stairs Leetcode
๐ŸŸข โœ… 746. Min Cost Climbing Stairs Leetcode
๐ŸŸข โœ…โ—โ“โŒ Leetcode
๐ŸŸ  โœ…โ—โ“โŒ Leetcode
๐Ÿ”ด โœ…โ—โ“โŒ Leetcode
  • 235: Binary search tree: left <= val <= right
  • 746: Build an array dp where dp[i] is the minimum cost to climb to the top starting from the ith staircase.

20220731

Difficulty Marks Name link Notes
๐ŸŸข โœ… 136. Single Number Leetcode
๐ŸŸข โœ…โ— 191. Number of 1 Bits Leetcode
๐ŸŸข โŒ 338. Counting Bits Leetcode
๐ŸŸข โœ… 190. Reverse Bits Leetcode
๐ŸŸข โœ…โ—โ“โŒ 268. Missing Number Leetcode
  • 191: use mod n = n % 2

20220802

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 208. Implement Trie (Prefix Tree) Leetcode
๐ŸŸ  โ“ 211. Design Add and Search Words Data Structure Leetcode
๐ŸŸ  โœ… 981. Time Based Key-Value Store Leetcode
๐ŸŸ  โœ… 973. K Closest Points to Origin Leetcode
๐ŸŸ  โœ… 215. Kth Largest Element in an Array Leetcode
๐ŸŸ  โœ… 78. Subsets Leetcode try to solve with single res: ArrayList
๐ŸŸ  โœ…โ—โ“โŒ 39. Combination Sum Leetcode S1

20220803

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 46. Permutations Leetcode
๐ŸŸ  โœ…โ—โ“โŒ 90. Subsets II Leetcode

20220804

Difficulty Marks Name link Notes
๐ŸŸ  โ“ 40. Combination Sum II Leetcode
๐ŸŸ  โœ…โ— 200. Number of Islands Leetcode

20220805

Difficulty Marks Name link Notes
๐ŸŸ  โœ…โ—โ“โŒ 695. Max Area of Island Leetcode
๐ŸŸ  โœ…โ—โ“โŒ 133. Clone Graph Leetcode

20220806

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 417. Pacific Atlantic Water Flow Leetcode revert: ocean to land
๐ŸŸ  โœ…โ—โ“โŒ 130. Surrounded Regions Leetcode

Note:

  • 130: reverse thinking, thanks all non-surrounded region to T and change all O to X then change Ts back to O

20220807

Difficulty Marks Name link Notes
๐ŸŸ  โœ…โ— 198. House Robber Leetcode

20220808

Difficulty Marks Name link Notes
๐ŸŸ  โœ…โ—โ“โŒ 322. Coin Change Leetcode
๐ŸŸ  โœ…โ—โ“โŒ 91. Decode Ways Leetcode

20220810

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 36. Valid Sudoku Leetcode
๐ŸŸ  โœ…โ—โ“โŒ 53. Maximum Subarray Leetcode

20220811

Difficulty Marks Name link Notes
๐ŸŸ  โœ…โ— 134. Gas Station Leetcode
๐ŸŸ  โœ…โ“โ“ 55. Jump Game Leetcode
๐ŸŸ  โœ…โ“ 45. Jump Game II Leetcode

Notes:

  • 55: M4
  • 134: S1

20220812

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 846. Hand of Straights Leetcode
๐ŸŸ  โœ…โ“ 57. Insert Interval Leetcode

20220813

Difficulty Marks Name link Notes
๐ŸŸ  โœ…โ—โ“โŒ 102. Binary Tree Level Order Traversal Leetcode

20220814

Difficulty Marks Name link Notes
๐ŸŸ  โœ… 199. Binary Tree Right Side View Leetcode
๐ŸŸ  โœ… 1448. Count Good Nodes in Binary Tree Leetcode
๐ŸŸ  โœ… 98. Validate Binary Search Tree Leetcode
๐ŸŸ  โœ…โ— 230. Kth Smallest Element in a BST Leetcode
๐ŸŸ  โœ…โ—โ—โ— 105. Construct Binary Tree from Preorder and Inorder Traversal Leetcode
๐ŸŸ  โœ…โ—โ“โŒ 211. Design Add and Search Words Data Structure Leetcode
๐ŸŸ  โœ…โ“ 621. Task Scheduler Leetcode

Notes:

  • bfs - order level traversal
  • 98: binary search tree - sorted order
  • 230: solution

20220815

Difficulty Marks Name link Notes
๐ŸŸข โœ…โ—โ“โŒ Leetcode
๐ŸŸ  โœ…โ“ 355. Design Twitter Leetcode
๐ŸŸ  โœ… 332. Reconstruct Itinerary Leetcode
๐ŸŸ  โœ…โ“ 1584. Min Cost to Connect All Points Leetcode

Notes:

  • 1584: Read S2 and link

2022081

Difficulty Marks Name link Notes
๐ŸŸข โœ…โ—โ“โŒ Leetcode
๐ŸŸ  โœ… 143. Reorder List Leetcode
๐ŸŸ  โœ… 146. LRU Cache Leetcode
๐ŸŸ  โœ… 23. Merge k Sorted Lists Leetcode
๐Ÿ”ด โœ… 25. Reverse Nodes in k-Group Leetcode
๐ŸŸ  211. Design Add and Search Words Data Structure Leetcode
๐ŸŸ  โ—โ“โŒ 4. Median of Two Sorted Arrays Leetcode
๐ŸŸ  โœ… 130. Surrounded Regions Leetcode

Notes:!!

  • 143: slow -> 0 and fast -> 1, fast jumps two steps while slow jumps one, when fast became null slow is at the end of the first half

202208

Difficulty Marks Name link
๐ŸŸ  โœ…โ—โ“โŒ 743. Network Delay Time Leetcode
๐ŸŸ  โœ…โ—โ“โŒ 295. Find Median from Data Stream Leetcode

20220824

Difficulty Marks Name link
๐ŸŸ  โœ… 79. Word Search Leetcode

20220825

Difficulty Marks Name link
๐ŸŸ  โŒ 131. Palindrome Partitioning Leetcode
๐ŸŸ  โœ…โ—โ“โŒ 17. Letter Combinations of a Phone Number Leetcode

20220826

Difficulty Marks Name link
๐ŸŸ  โœ… 663 ยท Walls and Gates Leetcode
๐ŸŸ  โœ… 207. Course Schedule Leetcode
  • 207: S1

20220827

Difficulty Marks Name link
๐ŸŸ  โœ…โ—โ“โŒ 684. Redundant Connection [Leetcode](// https://leetcode.com/problems/redundant-connection/)

20220828

Difficulty Marks Name link
๐ŸŸ  โœ… 2385. Amount of Time for Binary Tree to Be Infected Leetcode
  • 2385: S1

20220829

Difficulty Marks Name link
๐Ÿ”ด โœ…โ—โ“โŒ 4. Median of Two Sorted Arrays Leetcode

20220907

Difficulty Marks Name link
๐ŸŸ  โœ…โ—โ“โŒ 8. String to Integer (atoi) Leetcode
๐ŸŸ  โœ…โ—โ“โŒ 56. Merge Intervals Leetcode
  • 8: stupid ass question, not worth looking at

20220908

Difficulty Marks Name link
๐ŸŸ  โŒ 435. Non-overlapping Intervals Leetcode
๐ŸŸ  โœ…โ—โ“โŒ Lintcode 919 ยท Meeting Rooms II Leetcode youtube

20220911

Difficulty Marks Name link
๐ŸŸ  โœ… Leetcode
๐ŸŸ  โœ… 73. Set Matrix Zeroes Leetcode
๐ŸŸ  โœ… 50. Pow(x, n) Leetcode
๐ŸŸ  โŒ 371. Sum of Two Integers Leetcode
๐ŸŸข โœ… 202. Happy Number Leetcode
๐ŸŸข โœ… 66. Plus One Leetcode

20220912

Difficulty Marks Name link
๐ŸŸ  โœ… 338. Counting Bits Leetcode
๐ŸŸ  โœ…โ—โ“โŒ 91. Decode Ways Leetcode

20220914

Difficulty Marks Name link
๐ŸŸ  โœ…โ—โ“โŒ 213. House Robber II Leetcode
  • 213: run house robber 1 two times with either first house included or the last

20220916

Difficulty Marks Name link
๐ŸŸ  โœ…โ—โ“โŒ 322. Coin Change Leetcode

20220923

Diff Marks Name link
๐ŸŸ  โœ…โ— 743. Network Delay Time Leetcode
๐ŸŸ  โœ… 209. Minimum Size Subarray Sum Leetcode
๐ŸŸ  โœ…โ—โ“โŒ Leetcode
๐ŸŸ  โœ…โ—โ“โŒ Leetcode
๐ŸŸ  โœ…โ—โ“โŒ Leetcode
๐ŸŸข โœ…โ—โ“โŒ Leetcode
๐ŸŸข โœ…โ—โ“โŒ 977. Squares of a Sorted Array Leetcode
๐Ÿ”ด โœ…โ—โ“โŒ Leetcode
  • 209: sliding window (left/right pointers)

202209

Diff Marks Name link
๐ŸŸ  โœ…โ—โ“โŒ Leetcode
๐ŸŸ  โœ…โ—โ“โŒ Leetcode
๐ŸŸ  โœ…โ—โ“โŒ Leetcode
๐ŸŸ  โœ…โ—โ“โŒ Leetcode
๐ŸŸข โœ…โ—โ“โŒ Leetcode
๐Ÿ”ด โœ…โ—โ“โŒ Leetcode

Read List

  • Union-Find/Disjoint Set

TODO:

  • Quick sort
  • Quick select
  • depth first search

Binary search tree

  • when there are multiple same value (not distinct), how to get the left most index of the given value (or right)
  • l < r vs l <= r

backtrack / dfs

  • you can go either way
    • starting from position 0, and for each layer down the line you can either add or not add the next element (Leetcode_46), or
    • starting form all the element including, you can have any many children as the element, and for each child, consider the corresponding element removed (Leetcode_90)

References:

  • LeetCode Top 100 Problem Selection | Step-by-step Data Science
  • GitHub - youngyangyang04/leetcode-master: ๐Ÿš€ ใ€Šไปฃ็ ้šๆƒณๅฝ•ใ€‹LeetCode ๅˆท้ข˜ๆ”ป็•ฅ๏ผš200้“็ปๅ…ธ้ข˜็›ฎๅˆท้ข˜้กบๅบ
  • LABULADONG ็š„็ฎ—ๆณ•็ฝ‘็ซ™

To-Do list

  • https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/
  • https://leetcode.com/problems/graph-valid-tree/
  • https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
  • https://leetcode.com/problems/palindrome-partitioning/submissions/
  • https://leetcode.cn/problems/construct-binary-tree-from-preorder-and-inorder-traversal/

About

coding practice, mostly on leetcode

Resources

Readme
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 โ€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800ร—600. No cookies required.