Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbd52434

Browse files
committed
167
1 parent9ad3ada commitbd52434

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎ruby/167-Two-Sum-II.rb‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
deftwo_sum(numbers,target)
2+
idx_start=0
3+
idx_end=numbers.length -1
4+
whileidx_start <idx_end
5+
casenumbers[idx_start] +numbers[idx_end] <=>target
6+
when1
7+
idx_end -=1
8+
when0
9+
return[idx_start +1,idx_end +1]
10+
when -1
11+
idx_start +=1
12+
end
13+
end
14+
nil
15+
end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp