8000 update 1099 · githubniraj/Leetcode@f1b0562 · GitHub
[go: up one dir, main page]

Skip to content

Commit f1b0562

Browse files
update 1099
1 parent cc875bd commit f1b0562

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/main/java/com/fishercoder/solutions/_1099.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ public static class Solution1 {
88
* Time: O(n^2)
99
* Space: O(1)
1010
*/
11-
public int twoSumLessThanK(int[] A, int K) {
11+
public int twoSumLessThanK(int[] nums, int k) {
1212
int maxSum = Integer.MIN_VALUE;
13-
for (int i = 0; i < A.length - 1; i++) {
14-
for (int j = i + 1; j < A.length; j++) {
15-
if (A[i] + A[j] < K) {
16-
maxSum = Math.max(maxSum, A[i] + A[j]);
13+
for (int i = 0; i < nums.length - 1; i++) {
14+
for (int j = i + 1; j < nums.length; j++) {
15+
if (nums[i] + nums[j] < k) {
16+
maxSum = Math.max(maxSum, nums[i] + nums[j]);
1717
}
1818
}
1919
}
@@ -26,16 +26,16 @@ public static class Solution2 {
2626
* Time: O(nlogn)
2727
* Space: O(1)
2828
*/
29-
public int twoSumLessThanK(int[] A, int K) {
30-
Arrays.sort(A);
29+
public int twoSumLessThanK(int[] nums, int k) {
30+
Arrays.sort(nums);
3131
int left = 0;
32-
int right = A.length - 1;
32+
int right = nums.length - 1;
3333
int sum = Integer.MIN_VALUE;
3434
while (left < right) {
35-
int newSum = A[left] + A[right];
36-
if (newSum < K && newSum > sum) {
35+
int newSum = nums[left] + nums[right];
36+
if (newSum < k && newSum > sum) {
3737
sum = newSum;
38-
} else if (newSum >= K) {
38+
} else if (newSum >= k) {
3939
right--;
4040
} else {
4141
left++;

0 commit comments

Comments
 (0)
0