目录
1.Two Sum II - Input array is sorted(167)
4. Reverse Vowels of a String(345)
5.Kth Largest Element in an Array(215)
1.Two Sum II - Input array is sorted(167)
package com.problem167;
class Solution {
public int[] twoSum(int[] numbers, int target) {
int i = 0, j = numbers.length - 1;
int[] result = new int[2];
int temp;
while (i < j){
temp = numbers[i] + numbers[j];
if (temp == target){
result[0] = i + 1;
result[1] = j + 1;
break;
}else if (temp < target){
i++;
}else{
j--;
}
}
return result;
}
}
2. Sum of Square Numbers(633)
pack