Skip to content

Commit b167ef5

Browse files
committed
Runtime: 91 ms (Top 91.57%) | Memory: 51.6 MB (Top 89.43%)
1 parent cef7bf1 commit b167ef5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

scripts/algorithms/O/Online Election/Online Election.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
// Runtime: 91 ms (Top 91.57%) | Memory: 51.6 MB (Top 89.43%)
12
class TopVotedCandidate {
2-
int[] persons;
3+
int[] persons;
34
int[] times;
45
int length;
56
Map<Integer, Integer> voteCount;
67
Map<Integer, Integer> voteLead;
7-
8+
89
public TopVotedCandidate(int[] persons, int[] times) {
910
this.persons = persons;
1011
this.times = times;
@@ -23,7 +24,7 @@ public TopVotedCandidate(int[] persons, int[] times) {
2324
voteLead.put(times[i], leadPerson);
2425
}
2526
}
26-
27+
2728
public int q(int t) {
2829
int leadPerson = -1;
2930
if(voteLead.containsKey(t)) {
@@ -45,7 +46,6 @@ else if(t > times[length]){
4546
}
4647
leadPerson = voteLead.get(times[high]);
4748
}
48-
return leadPerson;
49+
return leadPerson;
4950
}
5051
}
51-

0 commit comments

Comments
 (0)