iT邦幫忙

algorithm相關文章
共有 320 則文章
LeetCode Top 100 Liked 系列 第 66

技術 [Day 64 ] Merge Intervals (Medium)

56. Merge Intervals Solution 1: Sort class Solution: def merge(self, interva...

LeetCode Top 100 Liked 系列 第 65

技術 [Day 63 ] Binary Tree Inorder Traversal (Easy)

94. Binary Tree Inorder Traversal Solution 1: Recursive class Solution: def...

LeetCode Top 100 Liked 系列 第 64

技術 [Day 62 ] Rotate Array (Medium)

189. Rotate Array Solution 1: Insert operation of the array (TLE) class Solution...

LeetCode Top 100 Liked 系列 第 63

技術 [Day 61 - 2] Unique Paths (Medium)

62. Unique Paths Solution 1: DFS (TLE) class Solution: def uniquePaths(self,...

LeetCode Top 100 Liked 系列 第 62

技術 [Day 61 - 1] Palindrome Linked List (Easy)

234. Palindrome Linked List Solution 1: Auxiliary array & reversed class Sol...

LeetCode Top 100 Liked 系列 第 61

技術 [Day 60 ] Majority Element (Easy)

169. Majority Element Solution 1: Counter from collections import Counter class...

LeetCode Top 100 Liked 系列 第 60

技術 [Day 59] Jump Game II (Medium)

45. Jump Game II Solution 0: Brute-Force + DP (看完題目第一個想法) class Solution: de...

LeetCode Top 100 Liked 系列 第 59

技術 [Day 58] Word Break (Medium)

139. Word Break Solution 1: DFS (TLE) class Solution: def wordBreak(self, s:...

LeetCode Top 100 Liked 系列 第 58

技術 [Day 57] Linked List Cycle II (Medium)

142. Linked List Cycle II Solution 1: HashSet class Solution: def detectCycl...

LeetCode Top 100 Liked 系列 第 57

技術 [Day 56] Sliding Window Maximum (Hard)

239. Sliding Window Maximum (Hard) Solution 1: Brute Force Time Complexity: O()...

LeetCode Top 100 Liked 系列 第 56

技術 [Day 55] Find First and Last Position of Element in Sorted Array (Medium)

34. Find First and Last Position of Element in Sorted Array Solution 1: Recursiv...

LeetCode Top 100 Liked 系列 第 55

技術 [Day 54 - 2] Construct Binary Tree from Preorder and Inorder Traversal (Medium)

105. Construct Binary Tree from Preorder and Inorder Traversal Solution 1: Recur...

LeetCode Top 100 Liked 系列 第 54

技術 [Day 54 - 1] Binary Tree Maximum Path Sum (Hard)

124. Binary Tree Maximum Path Sum Solution 1: DFS + Recursive # Definition for a...

LeetCode Top 100 Liked 系列 第 53

技術 [Day 53] Validate Binary Search Tree (Medium)

98. Validate Binary Search Tree Solution 1: DFS class Solution: def _isValid...

LeetCode Top 100 Liked 系列 第 52

技術 [Day 52] Linked List Cycle (Easy)

141. Linked List Cycle Solution 1: Hash class Solution: def hasCycle(self, h...

LeetCode Top 100 Liked 系列 第 51

技術 [Day 51] Move Zeroes (Easy)

283. Move Zeroes Solution 1: Two Pointers class Solution: def moveZeroes(sel...

LeetCode Top 100 Liked 系列 第 50

技術 [Day 50] First Missing Positive (Hard)

41. First Missing Positive Solution 1: Sort class Solution: def firstMissing...

LeetCode Top 100 Liked 系列 第 49

技術 [Day 49] String to Integer (Medium)

8. String to Integer (atoi) Solution 1: Brute-Force def myAtoi(self, s: str)...

LeetCode Top 100 Liked 系列 第 48

技術 [Day 48] Kth Largest Element in an Array (Medium)

215. Kth Largest Element in an Array Solution 1: Sort class Solution: def fi...

LeetCode Top 100 Liked 系列 第 47

技術 [Day 47] Maximum Product Subarray (Medium)

152. Maximum Product Subarray Solution 1: DP class Solution: def maxProduct(...

技術 Day 33 極致改良 - Shell Sort

Shell Sort 是 Insertion Sort 的改良版,加入了間距 (Gap) 的概念將資料分成小區塊,將整組資料分組,每區塊用 Insertion...

LeetCode Top 100 Liked 系列 第 46

技術 [Day 46] Zigzag Conversion (Medium)

6. Zigzag Conversion Solution 1: 2D-Array + Simulation (模擬 Z 字形移動) class Solutio...

LeetCode Top 100 Liked 系列 第 45

技術 [Day 45] Reverse Nodes in k-Group (Hard)

25. Reverse Nodes in k-Group Solution 1: Iterative class Solution: def rever...

LeetCode Top 100 Liked 系列 第 44

技術 [Day 44] Lowest Common Ancestor of a Binary Tree (Medium)

236. Lowest Common Ancestor of a Binary Tree Solution 1: DFS class Solution:...

LeetCode Top 100 Liked 系列 第 43

技術 [Day 43] Sort List (Medium)

148. Sort List Solution 1: Merge Sort # Definition for singly-linked list. # cla...

LeetCode Top 100 Liked 系列 第 42

技術 [Day 42] Unique Binary Search Trees (Medium)

96. Unique Binary Search Trees Solution 1: DP class Solution: def numTrees(s...

LeetCode Top 100 Liked 系列 第 41

技術 [Day 41] Next Permutation (Medium)

31. Next Permutation Solution 1: Two Pointer class Solution: ""&qu...

LeetCode Top 100 Liked 系列 第 40

技術 [Day 40] Subsets (Medium)

78. Subsets Solution 1: Bitwise class Solution(object): def subsets(self, nu...

LeetCode Top 100 Liked 系列 第 39

技術 [Day 39] Number of Islands (Medium)

200. Number of Islands Solution 1: DFS + Bitmap class Solution: def numIslan...

LeetCode Top 100 Liked 系列 第 38

技術 [Day 38] Minimum Window Substring (Hard)

76. Minimum Window Substring Solution 1: Slide Window + Hash from collections im...