-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
123 additions
and
9 deletions.
There are no files selected for viewing
4 changes: 0 additions & 4 deletions
4
.idea/sonarlint/issuestore/8/2/82933e8dbce0cd0d2bce4709cfc38147b0cda7b0
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* @author Cheng102e | ||
* @version 1.0 | ||
* @date 2020/2/16 14:17 | ||
*/ | ||
public class Q11 { | ||
|
||
public int maxArea(int[] height) { | ||
int left = 0, right = height.length - 1; | ||
int max = 0; | ||
while (left < right) { | ||
max = Math.max(max, (right - left) * Math.min(height[left], height[right])); | ||
if (height[left] < height[right]) { | ||
left++; | ||
} else { | ||
right--; | ||
} | ||
} | ||
return max; | ||
} | ||
|
||
public static void main(String[] args) { | ||
System.out.println("Hello World!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import java.util.PriorityQueue; | ||
|
||
/** | ||
* @author Cheng102e | ||
* @version 1.0 | ||
* @date 2020/2/16 12:12 | ||
*/ | ||
public class Q215 { | ||
|
||
public static int findKthLargest(int[] nums, int k) { | ||
PriorityQueue<Integer> heap = | ||
new PriorityQueue<Integer>((n1, n2) -> n1 - n2); | ||
for (int n : nums) { | ||
heap.add(n); | ||
if (heap.size() > k) { | ||
heap.poll(); | ||
} | ||
} | ||
return heap.poll(); | ||
} | ||
|
||
public static void main(String[] args) { | ||
System.out.println("Hello World!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @author Cheng102e | ||
* @version 1.0 | ||
* @date 2020/2/16 13:05 | ||
*/ | ||
public class Q344 { | ||
|
||
public void reverseString(char[] s) { | ||
int left = 0, right = s.length - 1; | ||
while (left < right) { | ||
char temp = s[left]; | ||
s[left] = s[right]; | ||
s[right] = temp; | ||
left++; | ||
right--; | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
System.out.println("Hello World!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @author Cheng102e | ||
* @version 1.0 | ||
* @date 2020/2/16 13:05 | ||
*/ | ||
public class Q345 { | ||
|
||
public static boolean find(char c) { | ||
return !(c == 'a' || c == 'o' || c == 'e' || c == 'i' || c == 'u' || c == 'A' || c == 'O' | ||
|| c == 'E' || c == 'I' || c == 'U'); | ||
} | ||
|
||
public static String reverseVowels(String s) { | ||
char[] arr = s.toCharArray(); | ||
int left = 0, right = arr.length - 1; | ||
while (left < right) { | ||
while (left < arr.length && find(arr[left])) { | ||
left++; | ||
} | ||
while (right >= 0 && find(arr[right])) { | ||
right--; | ||
} | ||
if (left >= right) { | ||
break; | ||
} | ||
char temp = arr[right]; | ||
arr[right--] = arr[left]; | ||
arr[left++] = temp; | ||
} | ||
String result = new String(arr); | ||
return result; | ||
} | ||
|
||
public static void main(String[] args) { | ||
System.out.println("Hello World!"); | ||
} | ||
} |