Skip to content

Commit 9da3521

Browse files
committed
Upsolved Weekly Contest 129
1 parent 1dfc480 commit 9da3521

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public int maxScoreSightseeingPair(int[] A) {
3+
int maxVal = 0;
4+
int currMax = 0;
5+
6+
for (int spot : A) {
7+
maxVal = Math.max(maxVal, currMax + spot);
8+
currMax = Math.max(spot, currMax) - 1;
9+
}
10+
11+
return maxVal;
12+
}
13+
}

Contests/Weekly Contest 129/Binary String With Substrings Representing 1 To N.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
class Solution {
22
public boolean queryString(String S, int N) {
33

4-
int num = 1;
5-
while (num <= N) {
4+
int num = N;
5+
while (num >= N / 2) {
66
if (S.indexOf(Integer.toBinaryString(num)) == -1) {
77
return false;
88
}
99

10-
num++;
10+
num--;
1111
}
1212

1313
return true;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public int smallestRepunitDivByK(int K) {
3+
if (K % 2 == 0 || K % 5 == 0) {
4+
return -1;
5+
}
6+
7+
int rem = 0;
8+
for (int i = 1; i <= K; i++) {
9+
rem = (rem * 10 + 1) % K;
10+
if (rem == 0) {
11+
return i;
12+
}
13+
}
14+
15+
return -1;
16+
}
17+
}

0 commit comments

Comments
 (0)