forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 1
/
_1985.java
24 lines (21 loc) · 784 Bytes
/
_1985.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.fishercoder.solutions;
import java.util.PriorityQueue;
public class _1985 {
public static class Solution1 {
public String kthLargestNumber(String[] nums, int k) {
PriorityQueue<String> maxHeap = new PriorityQueue<>((a, b) -> (a.length() != b.length() ? b.length() - a.length() : b.compareTo(a)));
for (String num : nums) {
maxHeap.offer(num);
}
while (k-- > 1) {
maxHeap.poll();
}
return maxHeap.peek();
}
}
public static void main(String... args) {
System.out.println("1234".compareTo("2345"));
System.out.println("2345".compareTo("1234"));
// System.out.println(String.valueOf(Long.MAX_VALUE).length());
}
}