Update worst_best_time_complexity,

leetcode_two_sum
This commit is contained in:
Yudong Jin
2023-02-03 18:53:15 +08:00
parent 592965595e
commit 70dead5cd0
24 changed files with 63 additions and 121 deletions

View File

@ -4,6 +4,7 @@
* Author: nuomi1 (nuomi1@qq.com)
*/
/* */
func twoSumBruteForce(nums: [Int], target: Int) -> [Int] {
// O(n^2)
for i in nums.indices.dropLast() {
@ -16,6 +17,7 @@ func twoSumBruteForce(nums: [Int], target: Int) -> [Int] {
return [0]
}
/* */
func twoSumHashTable(nums: [Int], target: Int) -> [Int] {
// O(n)
var dic: [Int: Int] = [:]