Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit898fba5

Browse files
committed
update: 374
1 parent5ab6c96 commit898fba5

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ This is the solutions collection of my LeetCode submissions, most of them are pr
110110
|342|[Power of Four](https://leetcode.com/problems/power-of-four/)|[JavaScript](./src/power-of-four/res.js)|Easy|
111111
|344|[Reverse String](https://leetcode.com/problems/reverse-string/)|[JavaScript](./src/reverse-string/res.js)|Easy|
112112
|371|[Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers/)|[JavaScript](./src/sum-of-two-integers/res.js)|Easy|
113+
|374|[Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower/)|[JavaScript](./src/guess-number-higher-or-lower/res.py)|Easy|
113114
|376|[Wiggle Subsequence](https://leetcode.com/problems/wiggle-subsequence/)|[JavaScript](./src/wiggle-subsequence/res.js)|Medium|
114115
|384|[Shuffle an Array](https://leetcode.com/problems/shuffle-an-array/)|[JavaScript](./src/shuffle-an-array/res.js)|Medium|
115116
|404|[Sum of Left Leaves](https://leetcode.com/problems/sum-of-left-leaves/)|[JavaScript](./src/sum-of-left-leaves/res.js)|Easy|
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# The guess API is already defined for you.
2+
# @param num, your guess
3+
# @return -1 if my number is lower, 1 if my number is higher, otherwise return 0
4+
# def guess(num):
5+
6+
# 此题无 JavaScript 提交入口
7+
classSolution(object):
8+
defguessNumber(self,n):
9+
left=1
10+
right=n
11+
whileleft<right:
12+
# mid = left + (right - left) // 2
13+
mid= (left+right)>>1
14+
ifguess(mid)==1:
15+
# 中位数比猜的数小,因此比中位数小的数包括中位数都不是目标元素
16+
left=mid+1
17+
else:
18+
right=mid
19+
# 最后剩下的数一定是所求,无需后处理
20+
returnleft

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp