File tree Expand file tree Collapse file tree 3 files changed +18
-21
lines changed
solution/0000-0099/0001.Two Sum Expand file tree Collapse file tree 3 files changed +18
-21
lines changed Original file line number Diff line number Diff line change @@ -254,16 +254,15 @@ class Solution {
254
254
* @return Integer[]
255
255
*/
256
256
function twoSum($nums, $target) {
257
- $len = count($nums);
258
- for ($i= 0; $i< $len; $i++) {
259
- for ($j=1+ $i; $j< $len; $j++) {
260
- if ($nums[$i]+ $nums[$j]== $target)
261
- {
262
- return [$i,$j];
257
+ $len = count($nums);
258
+ for ($i = 0; $i < $len; $i++) {
259
+ for ($j = 1 + $i; $j < $len; $j++) {
260
+ if ($nums[$i] + $nums[$j] == $target) {
261
+ return [$i, $j];
262
+ }
263
263
}
264
264
}
265
265
}
266
- }
267
266
}
268
267
```
269
268
Original file line number Diff line number Diff line change @@ -235,16 +235,15 @@ class Solution {
235
235
* @return Integer[]
236
236
*/
237
237
function twoSum($nums, $target) {
238
- $len = count($nums);
239
- for ($i= 0; $i< $len; $i++) {
240
- for ($j=1+ $i; $j< $len; $j++) {
241
- if ($nums[$i]+ $nums[$j]== $target)
242
- {
243
- return [$i,$j];
238
+ $len = count($nums);
239
+ for ($i = 0; $i < $len; $i++) {
240
+ for ($j = 1 + $i; $j < $len; $j++) {
241
+ if ($nums[$i] + $nums[$j] == $target) {
242
+ return [$i, $j];
243
+ }
244
244
}
245
245
}
246
246
}
247
- }
248
247
}
249
248
```
250
249
Original file line number Diff line number Diff line change @@ -6,14 +6,13 @@ class Solution {
6
6
* @return Integer[]
7
7
*/
8
8
function twoSum ($nums , $target ) {
9
- $len = count ($nums );
10
- for ($i = 0 ; $i < $len ; $i ++ ) {
11
- for ($j = 1 + $i ; $j < $len ; $j ++ ) {
12
- if ($nums [$i ]+ $nums [$j ]== $target )
13
- {
14
- return [ $i , $j ];
9
+ $len = count ($nums );
10
+ for ($i = 0 ; $i < $len ; $i ++ ) {
11
+ for ($j = 1 + $i ; $j < $len ; $j ++ ) {
12
+ if ($nums [$i ] + $nums [$j ] == $target ) {
13
+ return [ $i , $j ];
14
+ }
15
15
}
16
16
}
17
17
}
18
- }
19
18
}
You can’t perform that action at this time.
0 commit comments