雜湊表

雜湊表題型的解題教學,7 題。用空間換時間的經典做法,關鍵永遠是「要用什麼當 key」。

Encode and Decode Strings 解題教學示意圖|LeetCode 271

Encode and Decode Strings 解題教學:3 種解法完整比較|LeetCode 271 Best Practice

Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings.

Encode and Decode Strings 解題教學:3 種解法完整比較|LeetCode 271 Best Practice Read More »

Leetcode, 技術文章, , , ,
Group Anagrams 解題教學示意圖|LeetCode 49

Group Anagrams 解題教學:3 種解法完整比較|LeetCode 49 Best Practice

Given an array of strings strs, group the anagrams together. You can return the answer in any order.

An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.

Group Anagrams 解題教學:3 種解法完整比較|LeetCode 49 Best Practice Read More »

Leetcode, 技術文章, , , ,
Valid Anagram 解題教學示意圖|LeetCode 242

Valid Anagram 解題教學:3 種解法完整比較|LeetCode 242 Best Practice

Given two strings s and t, return true if t is an anagram of s, and false otherwise.

An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.

Valid Anagram 解題教學:3 種解法完整比較|LeetCode 242 Best Practice Read More »

Leetcode, 技術文章, , , ,
Longest Consecutive Sequence 解題教學示意圖|LeetCode 128

Longest Consecutive Sequence 解題教學:3 種解法完整比較|LeetCode 128 Best Practice

Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.

You must write an algorithm that runs in O(n) time.

Longest Consecutive Sequence 解題教學:3 種解法完整比較|LeetCode 128 Best Practice Read More »

Leetcode, 技術文章, , , ,
Product of Array Except Self 解題教學示意圖|LeetCode 238

Product of Array Except Self 解題教學:3 種解法完整比較|LeetCode 238 Best Practice

Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].

The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.

You must write an algorithm that runs in O(n) time and without using the division operation.

Product of Array Except Self 解題教學:3 種解法完整比較|LeetCode 238 Best Practice Read More »

Leetcode, 技術文章, , , ,
Contains Duplicate II 解題教學示意圖|LeetCode 219

Contains Duplicate II 解題教學:3 種解法完整比較|LeetCode 219 Best Practice

[LeetCode] 0219. Contains Duplicate II.
Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i – j) <= k

Contains Duplicate II 解題教學:3 種解法完整比較|LeetCode 219 Best Practice Read More »

Leetcode, 技術文章, , , ,
Contains Duplicate 解題教學示意圖|LeetCode 217

Contains Duplicate 解題教學:3 種解法完整比較|LeetCode 217 Best Practice

[LeetCode] 0217. Contains Duplicate.
Easy

Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

Contains Duplicate 解題教學:3 種解法完整比較|LeetCode 217 Best Practice Read More »

Leetcode, 技術文章, , , ,