Skip to content

Commit 07b4a17

Browse files
authored
Create 16 Nov Sum of Beauty of All Substrings
1 parent e8bc819 commit 07b4a17

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public:
3+
int guessNumber(int n) {
4+
int s = 1;
5+
int e = n;
6+
int mid = s + (e-s)/2;
7+
while(s <= e){
8+
if(guess(mid) == 0){
9+
return mid;
10+
}
11+
else if(guess(mid) == 1){
12+
s = mid +1;
13+
}
14+
else if(guess(mid) == -1){
15+
e = mid -1;
16+
}
17+
mid = s + (e-s)/2;
18+
}
19+
return -1;
20+
}
21+
};

0 commit comments

Comments
 (0)