Conversation
nodchip
reviewed
Mar 22, 2026
| return 0.0; | ||
| } | ||
|
|
||
| long long exp = n; |
|
|
||
| long long exp = n; | ||
|
|
||
| if (exp < 0) { |
There was a problem hiding this comment.
真の場合の処理と偽の場合の処理が対称になっているため、自分なら early return はしないと思います。
if (exp >= 0) {
return myPowHelper(x, exp);
} else {
return 1 / myPowHelper(x, -exp);
}| return 0.0; | ||
| } | ||
|
|
||
| long long exp = n; |
There was a problem hiding this comment.
exp という変数名は、標準ライブラリの std::exp と被っているため、避けたほうが良いかもしれません。
https://cpprefjp.github.io/reference/cmath/exp.html
Owner
Author
There was a problem hiding this comment.
コメントありがとうございます。
標準ライブラリに std::exp があるんですね。以後、気を付けます。
|
コメントされている箇所以外は、特に違和感ありませんでした 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
今回の問題
https://leetcode.com/problems/powx-n/
次の問題
https://leetcode.com/problems/k-th-symbol-in-grammar/