Skip to content

Commit bdfca9f

Browse files
authored
Update 1_TwoSum.rb
1 parent cb011dc commit bdfca9f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

HashTable/1_TwoSum.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# https://leetcode.com/problems/two-sum/description
44
#
55
# Language: Ruby
6-
# Auther: ConradG
6+
# Author: ConradG
77
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
88
# 第一反应为双循环遍历,发现题目归类于 Hash Table 中后也尝试使Hash Table 进行处理。
99
# 在单线程场景下,使用Hash的方式有更优秀的时间复杂度,而双循环则更易拆分为多个线程。
@@ -20,3 +20,10 @@ def two_sum(nums, target)
2020
num, i = nums.each_with_index.detect {|(num, i)| s[target - num] || !s[num] = i}
2121
[s[target - num], i]
2222
end
23+
24+
#
25+
# 19 / 19 test cases passed.
26+
# Status: Accepted
27+
# Runtime: 57 ms
28+
# Your runtime beats 75.07 % of ruby submissions.
29+
#

0 commit comments

Comments
 (0)