-
-
Couldn't load subscription status.
- Fork 9.1k
Add Solution.java for 0173 #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
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
@toeii
toeii
changed the title
(削除) leetcode 0173 java code (削除ここまで)
(追記) Add Solution.java for 0173 (追記ここまで)
Jul 11, 2019
yanglbme
yanglbme
requested changes
Jul 11, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @toeii ,请按照 doocs/leetcode 仓库的规范提交 leetcode 题解。
我推荐直接在 leetcode 平台上练习,你只需要将 AC 的代码放入 Solution.java 中,然后在 doocs/leetcode 上提交。
下面是我在你代码基础上做出的修改,以符合项目规范。
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ class BSTIterator { private TreeNode currentNode = null; private Stack<TreeNode> stack = new Stack<TreeNode>(); public BSTIterator(TreeNode root) { if (root != null) { currentNode = root; } } /** @return the next smallest number */ public int next() { while (currentNode != null) { stack.push(currentNode); currentNode = currentNode.left; } currentNode = stack.pop(); TreeNode node = currentNode; currentNode = currentNode.right; return node.val; } /** @return whether we have a next smallest number */ public boolean hasNext() { return currentNode != null || !stack.isEmpty(); } } /** * Your BSTIterator object will be instantiated and called as such: * BSTIterator obj = new BSTIterator(root); * int param_1 = obj.next(); * boolean param_2 = obj.hasNext(); */
以前所有题解都采用该方式,为了确保项目的规范统一,此后所有提交的代码都需要按照以上方式。
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.
No description provided.