Skip to content

Commit

Permalink
feat: azl397985856#230 add java solution(azl397985856#249)
Browse files Browse the repository at this point in the history
* correct typos

* Add translations

* 新增HTTP/1.0, HTTP/1.1, HTTP/2的对比

* 增加HTTP/1.1和HTTP/2的性能对比的Demo

* 翻译大部分基础数据结构,但是REACT部分没有翻译

* update description of `HTTP/1.0`

* add WIP tag, update some translation details

* change 'fundamental' to 'basic'

* remove some trivial details about HTTP/1.0

* error correction

* translation for DP

* translation for string problems

* error correction

* correct wrongly typed

* translation for binary-tree-traversal.md

* correct wrongly typed

* update README.en.md

* update description  of Huffman encoding

* update file path of Binary-tree-traversal-en.md.

* correct wrongly typed

* update paths of thinkings

* translation for basic-algorithm.md (Draft)

* translation for bloom-filter.md

* add java solution with inorder traversing

* Update 230.kth-smallest-element-in-a-bst.md

Co-authored-by: lucifer <[email protected]>
  • Loading branch information
StoneLyu and azl397985856 committed Dec 24, 2019
1 parent 6c054ff commit a4c8173
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions problems/230.kth-smallest-element-in-a-bst.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ What if the BST is modified (insert/delete operations) often and you need to fin

解法一:

JavaScript Code:

```js


Expand Down Expand Up @@ -107,9 +109,44 @@ var kthSmallest = function(root, k) {
};
```

Java Code:

```java
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
private int count = 1;
private int res;

public int KthSmallest (TreeNode root, int k) {
inorder(root, k);
return res;
}

public void inorder (TreeNode root, int k) {
if (root == null) return;

inorder(root.left, k);

if (count++ == k) {
res = root.val;
return;
}

inorder(root.right, k);
}
```

解法二:

JavaScript Code:

```js

/**
Expand Down

0 comments on commit a4c8173

Please sign in to comment.