242. Valid Anagram 給定兩個字串 s 和 t,判斷 t 是否為 s 的Anagram。Anagram 是指兩個字串中出現的字母相同,且每個字母的出現次數也相同,但順序可以不同。 簡單...
原文題目Given an unsorted array of integers nums, return the length of the longest consecutive elements...
數位簽章的 sign 和 verify 裡面都有把訊息(message)雜湊(hash)起來的雜湊函式。雜湊函數(hash functions)與資料完整性(data integrity)可以怎麼理解...
Hash 函數 Hash 函數是一種將任意長度的輸入轉換為固定長度輸出的算法,輸出被稱為哈希值(hash value)。好的哈希函數具有以下特性: 不可逆性:給定輸出,幾乎不可能反推出輸入。 抗...
350. Intersection of Two Arrays II 給定兩個整數數組 nums1 和 nums2,返回兩個數組的交集。輸出結果中的每個元素應該與其在兩個數組中出現的次數一致(也就是交...
原文題目 Given an array of strings strs, group the anagrams together. You can return the answer in any o...
217. Contains Duplicate 給定一個整數數組 nums,判斷其中是否存在重複元素。如果任意數字在數組中出現至少兩次,返回 true;如果所有元素互不相同,則返回 false。 程式...
Hash 學習影片 https://www.youtube.com/watch?v=eH5ihbNHD70https://www.youtube.com/watch?v=O4dGJZ4J0Bk Has...
重新分析一下昨天牛刀小試的例子, 我們在 addToCart() 的函式中用了 includes() 和 unshift() 兩個時間複雜度皆為 O(n) 的函式,先是走訪一次 n 個購物車的 Ite...
雜湊法(Hahing)是一種資料存取技術,通過將資料映射到一個特定的地址,實現快速的查找、插入和刪除操作。其核心原理是使用一個雜湊函數(Hash Function)來計算資料的雜湊值(Hash Val...