/leetcode

LeetCode practice in Golang

Primary LanguageGoMIT LicenseMIT

LeetCode Solutions in Golang

My LeetCode Practice

Features:

  • Written in Go
  • Thoughts are included in comments

Aims:

  • Algorithm
  • Data Structure
  • Golang

Solution Overview

Easy: 104/327 Medium: 39/566 Hard: 3/234

Solution

# Name Difficulty Tags
1 Two Sum [Solution] Easy Array Hash Table
2 Add Two Numbers [Solution] Medium Linked List Math
4 Median of Two Sorted Arrays [Solution] Hard Array Binary Search Divide and Conquer
5 Longest Palindromic Substring [Solution] Medium String Dynamic Programming
7 Reverse Integer [Solution] Easy Math
9 Palindrome Number [Solution] Easy Math
13 Roman to Integer [Solution] Easy Math String
14 Longest Common Prefix [Solution] Easy String
20 Valid Parentheses [Solution] Easy String Stack
21 Merge Two Sorted Lists [Solution] Easy Linked List
24 Swap Nodes in Pairs [Solution] Medium Linked List
26 Remove Duplicates from Sorted Array [Solution] Easy Array Two Pointers
27 Remove Element [Solution] Easy Array Two Pointers
28 Implement strStr() [Solution] Easy Two Pointers String
38 Count and Say [Solution] Easy String
53 Maximum Subarray [Solution] Easy Array Divide and Conquer Dynamic Programming
58 Length of Last Word [Solution] Easy String
66 Plus One [Solution] Easy Array
67 Add Binary [Solution] Easy Math String
70 Climbing Stairs [Solution] Easy Dynamic Programming
71 Simplify Path [Solution] Medium String Stack
83 Remove Duplicates from Sorted List [Solution] Easy Linked List
88 Merge Sorted Array [Solution] Easy Array Two Pointers
94 Binary Tree Inorder Traversal [Solution] Medium Hash Table Stack Tree
96 Unique Binary Search Trees [Solution] Medium Dynamic Programming Tree
100 Same Tree [Solution] Easy Tree Depth-first Search
101 Symmetric Tree [Solution] Easy Tree Depth-first Search Breadth-first Search
102 Binary Tree Level Order Traversal [Solution] Medium Tree Breadth-first Search
103 Binary Tree Zigzag Level Order Traversal [Solution] Medium Stack Tree Breadth-first Search
104 Maximum Depth of Binary Tree [Solution] Easy Tree Depth-first Search
105 Construct Binary Tree from Preorder and Inorder Traversal [Solution] Medium Array Tree Depth-first Search
106 Construct Binary Tree from Inorder and Postorder Traversal [Solution] Medium Array Tree Depth-first Search
107 Binary Tree Level Order Traversal II [Solution] Easy Tree Breadth-first Search
108 Convert Sorted Array to Binary Search Tree [Solution] Easy Tree Depth-first Search
109 Convert Sorted List to Binary Search Tree [Solution] Medium Linked List Depth-first Search
110 Balanced Binary Tree [Solution] Easy Tree Depth-first Search
111 Minimum Depth of Binary Tree [Solution] Easy Tree Depth-first Search Breadth-first Search
112 Path Sum [Solution] Easy Tree Depth-first Search
113 Path Sum II [Solution] Medium Tree Depth-first Search
114 Flatten Binary Tree to Linked List [Solution] Medium Tree Depth-first Search
116 Populating Next Right Pointers in Each Node [Solution] Medium Tree Depth-first Search
117 Populating Next Right Pointers in Each Node II [Solution] Medium Tree Depth-first Search
118 Pascal's Triangle [Solution] Easy Array
121 Best Time to Buy and Sell Stock [Solution] Easy Array Dynamic Programming
122 Best Time to Buy and Sell Stock II [Solution] Easy Array Greedy
125 Valid Palindrome [Solution] Easy Two Pointers String
129 Sum Root to Leaf Numbers [Solution] Medium Tree Depth-first Search
136 Single Number [Solution] Easy Hash Table Bit Manipulation
141 Linked List Cycle [Solution] Easy Linked List Two Pointers
144 Binary Tree Preorder Traversal [Solution] Medium Stack Tree
145 Binary Tree Postorder Traversal [Solution] Hard Stack Tree
146 LRU Cache [Solution] Medium Design
155 Min Stack [Solution] Easy Stack Design
175 Combine Two Tables [Solution] Easy
176 Second Highest Salary [Solution] Easy
177 Nth Highest Salary [Solution] Medium
181 Employees Earning More Than Their Managers [Solution] Easy
182 Duplicate Emails [Solution] Easy
183 Customers Who Never Order [Solution] Easy
184 Department Highest Salary [Solution] Medium
189 Rotate Array [Solution] Easy Array
197 Rising Temperature [Solution] Easy
199 Binary Tree Right Side View [Solution] Medium Tree Depth-first Search Breadth-first Search
203 Remove Linked List Elements [Solution] Easy Linked List
206 Reverse Linked List [Solution] Easy Linked List
225 Implement Stack using Queues [Solution] Easy Stack Design
226 Invert Binary Tree [Solution] Easy Tree
232 Implement Queue using Stacks [Solution] Easy Stack Design
234 Palindrome Linked List [Solution] Easy Linked List Two Pointers
235 Lowest Common Ancestor of a Binary Search Tree [Solution] Easy Tree
237 Delete Node in a Linked List [Solution] Easy Linked List
257 Binary Tree Paths [Solution] Easy Tree Depth-first Search
262 Trips and Users [Solution] Hard
283 Move Zeroes [Solution] Easy Array Two Pointers
342 Power of Four [Solution] Easy Bit Manipulation
388 Longest Absolute File Path [Solution] Medium
404 Sum of Left Leaves [Solution] Easy Tree
429 N-ary Tree Level Order Traversal [Solution] Easy Tree Breadth-first Search
445 Add Two Numbers II [Solution] Medium Linked List
449 Serialize and Deserialize BST [Solution] Medium Tree
461 Hamming Distance [Solution] Easy Bit Manipulation
496 Next Greater Element I [Solution] Easy Stack
513 Find Bottom Left Tree Value [Solution] Medium Tree Depth-first Search Breadth-first Search
515 Find Largest Value in Each Tree Row [Solution] Medium Tree Depth-first Search Breadth-first Search
530 Minimum Absolute Difference in BST [Solution] Easy Tree
538 Convert BST to Greater Tree [Solution] Easy Tree
543 Diameter of Binary Tree [Solution] Easy Tree
557 Reverse Words in a String III [Solution] Easy String
559 Maximum Depth of N-ary Tree [Solution] Easy Tree Depth-first Search Breadth-first Search
561 Array Partition I [Solution] Easy Array
563 Binary Tree Tilt [Solution] Easy Tree
572 Subtree of Another Tree [Solution] Easy Tree
589 N-ary Tree Preorder Traversal [Solution] Easy Tree
590 N-ary Tree Postorder Traversal [Solution] Easy Tree
595 Big Countries [Solution] Easy
596 Classes More Than 5 Students [Solution] Easy
606 Construct String from Binary Tree [Solution] Easy String Tree
617 Merge Two Binary Trees [Solution] Easy Tree
620 Not Boring Movies [Solution] Easy
623 Add One Row to Tree [Solution] Medium Tree
626 Exchange Seats [Solution] Medium
627 Swap Salary [Solution] Easy
637 Average of Levels in Binary Tree [Solution] Easy Tree
653 Two Sum IV - Input is a BST [Solution] Easy Tree
654 Maximum Binary Tree [Solution] Medium Tree
655 Print Binary Tree [Solution] Medium Tree
657 Robot Return to Origin [Solution] Easy String
669 Trim a Binary Search Tree [Solution] Easy Tree
671 Second Minimum Node In a Binary Tree [Solution] Easy Tree
674 Longest Continuous Increasing Subsequence [Solution] Easy Array
680 Valid Palindrome II [Solution] Easy String
682 Baseball Game [Solution] Easy Stack
700 Search in a Binary Search Tree [Solution] Easy Tree
707 Design Linked List [Solution] Easy Linked List Design
709 To Lower Case [Solution] Easy String
725 Split Linked List in Parts [Solution] Medium Linked List
728 Self Dividing Numbers [Solution] Easy Math
739 Daily Temperatures [Solution] Medium Hash Table Stack
766 Toeplitz Matrix [Solution] Easy Array
771 Jewels and Stones [Solution] Easy Hash Table
783 Minimum Distance Between BST Nodes [Solution] Easy Tree Recursion
804 Unique Morse Code Words [Solution] Easy String
807 Max Increase to Keep City Skyline [Solution] Medium
814 Binary Tree Pruning [Solution] Medium Tree
817 Linked List Components [Solution] Medium Linked List
832 Flipping an Image [Solution] Easy Array
844 Backspace String Compare [Solution] Easy Two Pointers Stack
852 Peak Index in a Mountain Array [Solution] Easy Binary Search
860 Lemonade Change [Solution] Easy Greedy
872 Leaf-Similar Trees [Solution] Easy Tree Depth-first Search
876 Middle of the Linked List [Solution] Easy Linked List
883 Projection Area of 3D Shapes [Solution] Easy Math
889 Construct Binary Tree from Preorder and Postorder Traversal [Solution] Medium Tree
890 Find and Replace Pattern [Solution] Medium String
894 All Possible Full Binary Trees [Solution] Medium Tree Recursion
897 Increasing Order Search Tree [Solution] Easy Tree Depth-first Search
905 Sort Array By Parity [Solution] Easy Array
921 Minimum Add to Make Parentheses Valid [Solution] Medium Stack Greedy
922 Sort Array By Parity II [Solution] Easy Array Sort
929 Unique Email Addresses [Solution] Easy String
938 Range Sum of BST [Solution] Easy Tree Recursion
965 Univalued Binary Tree [Solution] Easy Tree
993 Cousins in Binary Tree [Solution] Easy Tree Breadth-first Search
1021 Remove Outermost Parentheses [Solution] Easy Stack
1022 Sum of Root To Leaf Binary Numbers [Solution] Easy Tree
1047 Remove All Adjacent Duplicates In String [Solution] Easy Stack