File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed
src/com/blankj/medium/_016 Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -24,17 +24,17 @@ public class Solution {
2424 Arrays . sort(nums);
2525 int len = nums. length - 2 ;
2626 for (int i = 0 ; i < len; i++ ) {
27- int st = i + 1 , end = nums. length - 1 ;
28- while (st < end ) {
29- int sum = nums[i] + nums[st ] + nums[end ];
27+ int left = i + 1 , right = nums. length - 1 ;
28+ while (left < right ) {
29+ int sum = nums[i] + nums[left ] + nums[right ];
3030 int curDelta = Math . abs(sum - target);
3131 if (curDelta == 0 ) return sum;
3232 if (curDelta < delta) {
3333 delta = curDelta;
3434 res = sum;
3535 }
36- if (sum > target) -- end ;
37- else ++ st ;
36+ if (sum > target) -- right ;
37+ else ++ left ;
3838 }
3939 }
4040 return res;
Original file line number Diff line number Diff line change @@ -16,17 +16,17 @@ public int threeSumClosest(int[] nums, int target) {
1616 Arrays .sort (nums );
1717 int len = nums .length - 2 ;
1818 for (int i = 0 ; i < len ; i ++) {
19- int st = i + 1 , end = nums .length - 1 ;
20- while (st < end ) {
21- int sum = nums [i ] + nums [st ] + nums [end ];
19+ int left = i + 1 , right = nums .length - 1 ;
20+ while (left < right ) {
21+ int sum = nums [i ] + nums [left ] + nums [right ];
2222 int curDelta = Math .abs (sum - target );
2323 if (curDelta == 0 ) return sum ;
2424 if (curDelta < delta ) {
2525 delta = curDelta ;
2626 res = sum ;
2727 }
28- if (sum > target ) --end ;
29- else ++st ;
28+ if (sum > target ) --right ;
29+ else ++left ;
3030 }
3131 }
3232 return res ;
You can’t perform that action at this time.
0 commit comments