File tree Expand file tree Collapse file tree 1 file changed +16
-16
lines changed
solution/0000-0099/0001.Two Sum Expand file tree Collapse file tree 1 file changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -321,6 +321,22 @@ class Solution {
321
321
}
322
322
```
323
323
324
+ #### Nim
325
+
326
+ ``` nim
327
+ import std/enumerate
328
+ import std/tables
329
+
330
+ proc twoSum(nums: seq[int], target: int): seq[int] =
331
+ var d = initTable[int, int]()
332
+ for i, x in nums.pairs():
333
+ let y = target - x
334
+ if d.hasKey(y):
335
+ return @[d[y], i]
336
+ d[x] = i
337
+ return @[]
338
+ ```
339
+
324
340
#### Cangjie
325
341
326
342
``` cj
@@ -338,22 +354,6 @@ class Solution {
338
354
}
339
355
```
340
356
341
- #### Nim
342
-
343
- ``` nim
344
- import std/enumerate
345
- import std/tables
346
-
347
- proc twoSum(nums: seq[int], target: int): seq[int] =
348
- var d = initTable[int, int]()
349
- for i, x in nums.pairs():
350
- let y = target - x
351
- if d.hasKey(y):
352
- return @[d[y], i]
353
- d[x] = i
354
- return @[]
355
- ```
356
-
357
357
<!-- tabs: end -->
358
358
359
359
<!-- solution: end -->
You can’t perform that action at this time.
0 commit comments