iT邦幫忙

資料結構與演算法相關文章
共有 326 則文章

技術 Day26 Trie題目:208. Implement Trie (Prefix Tree)

原文題目 A trie (pronounced as "try") or prefix tree is a tree data struct...

技術 Day25 演算法介紹:字典樹(Trie)

字典樹(Trie) 是一種專門用來處理字串(單字)的樹狀結構,特別適合解決字串(單字)集合中的「前綴匹配」問題。它的每個節點代表一個字母,並且從根節點到某個葉節...

技術 Day24 Matrix題目3:240. Search a 2D Matrix II

原文題目 Write an efficient algorithm that searches for a value target in an m x n i...

技術 Day23 Matrix題目2:73. Set Matrix Zeroes

原文題目 Given an m x n integer matrix matrix, if an element is 0, set its entire ro...

技術 Day22 Matrix題目1:48. Rotate Image

原文題目 You are given an n x n 2D matrix representing an image, rotate the image by...

技術 Day21 演算法介紹:矩陣(Matrix)

矩陣(Matrix) 與基本的陣列結構息息相關,有點類似於二維陣列,它是一個利用mxn的陣列來介紹矩陣擁有m列和n行。而一般資料結構與演算法上常用到的矩陣有四種...

技術 Day20 演算法介紹:Stack與Heap的差異

最近兩個主題我們談到了「堆疊 (Stack)」和「堆積 (Heap)」,即使它們在中文上只有一字之差,但在電腦科學中,它們的用途和特性是非常不同的。 1. 堆疊...

技術 Day19 Stack題目3:739. Daily Temperatures

原文題目 Given an array of integers temperatures represents the daily temperatures,...

技術 Day18 Stack題目2:394. Decode String

原文題目 Given an encoded string, return its decoded string. The encoding rule is: k...

技術 Day17 Stack題目1:155. Min Stack

原文題目 Design a stack that supports push, pop, top, and retrieving the minimum ele...

技術 Day16 演算法介紹:堆疊(Stack)

堆疊演算法(Stack) 是一種有序串列(即一群相同資料型態的組合),具有「後進先出」(Last In First Out, LIFO)的特性,故其所有的動作、...

技術 Day15 Heap題目2:347. Top K Frequent Elements

原文題目 Given an integer array nums and an integer k, return the k most frequent el...

技術 Day14 Heap題目1:215. Kth Largest Element in an Array

原文題目 Given an integer array nums and an integer k, return the kth largest elemen...

技術 Day13 演算法介紹:堆積(Heap)

堆積(Heap) 是一種特殊且完整的二元樹,可分為最大/小堆積樹兩種。最大堆積樹中所有節點的值都大或等於它左右子節點的值,這兩種樹的樹根(root)是其堆積樹中...

技術 Day12 Greedy Algorithm題目3:45. Jump Game II

原文題目 You are given a 0-indexed array of integers nums of length n. You are initi...

技術 Day11 Greedy Algorithm題目2:55. Jump Game

原文題目 You are given an integer array nums. You are initially positioned at the ar...

技術 Day10 Greedy Algorithm題目1:121. Best Time to Buy and Sell Stock

原文題目 You are given an array prices where prices[i] is the price of a given stock...

技術 Day9 演算法介紹:貪婪(Greedy Algorithm)

貪婪演算法(Greedy Algorithm) 又稱作貪心法,簡單來說,此演算法是在每一個步驟使用貪心原則,只考慮當前情況的前提下選擇最優解法。其精神在於「只做...

技術 Day8 Dynamic Programming 題目3:139. Word Break

原文題目 Given a string s and a dictionary of strings wordDict, return true if s can...

技術 Day7 Dynamic Programming 題目2:198. House Robber

原文題目 You are a professional robber planning to rob houses along a street. Each h...

技術 Day6 Dynamic Programming 題目1 :70. Climbing Stairs

原文題目 You are climbing a staircase. It takes n steps to reach the top. Each time...

技術 Day5 演算法介紹:動態規劃(Dynamic Programming)

動態規劃(Dynamic Programming) 動態規劃是一種有效率計算由子問題堆疊而成的演算法,是一種常見的解題方式。透過將問題分解成許多可以利用簡單方法...

技術 Day4 Binary Search 題目3:74. Search a 2D Matrix

原文題目 You are given an m x n integer matrix matrix with the following two propert...

技術 Day3 Binary Search 題目2:35. Search Insert Position

原文題目 Given a sorted array of distinct integers and a target value, return the in...

技術 Day2 Binary Search 題目1:33. Search in Rotated Sorted Array

原文題目 There is an integer array nums sorted in ascending order (with distinct val...

技術 Day1 演算法介紹:二元搜尋法(Binary Search)

二元搜尋法(Binary Search),又稱作二分搜尋法、對數搜尋,是一個在已排序的序列中,快速找出特定元素的搜尋演算法。此種搜尋法會先將各元素做排序,並且每...

技術 參賽源起&複習對數與常見數學公式-day1

緣起 又來到了痛苦的鐵人賽發文季,老實說忘記去年為何沒參加了XD不過最近剛好在上線上課程資料結構與演算法 (JavaScript),覺得可以來記錄一下,順便看看...

技術 演算法筆記(Ch1~6)

Ch 1 Ch 1.1 Ch 1.2 Ch1.3 Ch2 Ch2.3 Ch 2.4 Ch...

技術 [Pyhton][資料結構]字串比對

先比對樣式的最後一個字元,再從頭開始比對 def match(pat,txt): lastt=len(txt)-1 lastp=len(pat)...

技術 [Pyhton][資料結構]稀疏矩陣(三)

給定兩個稀疏矩陣,並用三元序對表示: sparse1 = [ [5, 6, 4], [1, 2, 3],...