We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cb011dc commit bdfca9fCopy full SHA for bdfca9f
HashTable/1_TwoSum.rb
@@ -3,7 +3,7 @@
3
# https://leetcode.com/problems/two-sum/description
4
#
5
# Language: Ruby
6
-# Auther: ConradG
+# Author: ConradG
7
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
8
# 第一反应为双循环遍历,发现题目归类于 Hash Table 中后也尝试使Hash Table 进行处理。
9
# 在单线程场景下,使用Hash的方式有更优秀的时间复杂度,而双循环则更易拆分为多个线程。
@@ -20,3 +20,10 @@ def two_sum(nums, target)
20
num, i = nums.each_with_index.detect {|(num, i)| s[target - num] || !s[num] = i}
21
[s[target - num], i]
22
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