chore(java): format

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2024-03-02 21:01:53 +01:00
parent c6dfb95ec0
commit f0cdb67ac1
Signed by: mfocko
GPG key ID: 7C47D46246790496
21 changed files with 520 additions and 532 deletions

View file

@ -20,8 +20,13 @@ class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode() {}
TreeNode(int val) { this.val = val; }
TreeNode(int val) {
this.val = val;
}
TreeNode(int val, TreeNode left, TreeNode right) {
this.val = val;
this.left = left;
@ -31,7 +36,8 @@ class TreeNode {
class BSTIterator {
private enum Position {
Todo, Done
Todo,
Done
}
private class Entry {
@ -58,16 +64,15 @@ class BSTIterator {
}
private ArrayDeque<Entry> stack = new ArrayDeque<>();
public BSTIterator(TreeNode root) {
stack.addLast(new Entry(root, Position.Todo));
}
public int next() {
for (
Entry last = stack.getLast();
for (Entry last = stack.getLast();
last != null && last.position == Position.Todo;
last = stack.getLast()
) {
last = stack.getLast()) {
stack.removeLast().expand(stack);
}
@ -81,8 +86,6 @@ class BSTIterator {
}
/**
* 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();
* 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();
*/

View file

@ -1,17 +1,7 @@
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode() {}
* TreeNode(int val) { this.val = val; }
* TreeNode(int val, TreeNode left, TreeNode right) {
* this.val = val;
* this.left = left;
* this.right = right;
* }
* }
* Definition for a binary tree node. public class TreeNode { int val; TreeNode left; TreeNode
* right; TreeNode() {} TreeNode(int val) { this.val = val; } TreeNode(int val, TreeNode left,
* TreeNode right) { this.val = val; this.left = left; this.right = right; } }
*/
class Solution {
private TreeNode sortedArrayToBST(int[] nums, int min, int max) {
@ -21,10 +11,7 @@ class Solution {
int mid = (min + max) / 2;
return new TreeNode(
nums[mid],
sortedArrayToBST(nums, min, mid - 1),
sortedArrayToBST(nums, mid + 1, max)
);
nums[mid], sortedArrayToBST(nums, min, mid - 1), sortedArrayToBST(nums, mid + 1, max));
}
public TreeNode sortedArrayToBST(int[] nums) {

View file

@ -7,9 +7,11 @@ import java.util.List;
interface NestedInteger {
// @return true if this NestedInteger holds a single integer, rather than a nested list.
public boolean isInteger();
// @return the single integer that this NestedInteger holds, if it holds a single integer
// Return null if this NestedInteger holds a nested list
public Integer getInteger();
// @return the nested list that this NestedInteger holds, if it holds a nested list
// Return empty list if this NestedInteger holds a single integer
public List<NestedInteger> getList();
@ -97,7 +99,6 @@ class NestedIterator implements Iterator<Integer> {
}
/**
* Your NestedIterator object will be instantiated and called as such:
* NestedIterator i = new NestedIterator(nestedList);
* while (i.hasNext()) v[f()] = i.next();
* Your NestedIterator object will be instantiated and called as such: NestedIterator i = new
* NestedIterator(nestedList); while (i.hasNext()) v[f()] = i.next();
*/

View file

@ -11,11 +11,9 @@ class Solution {
dp[0][0] = 1;
for (int toss = 1; toss <= n; ++toss) {
for (
int sumIdx = toss, maxSumIdx = Math.min(target, toss * k);
for (int sumIdx = toss, maxSumIdx = Math.min(target, toss * k);
sumIdx <= maxSumIdx;
++sumIdx
) {
++sumIdx) {
for (int f = 1; f <= Math.min(k, sumIdx); ++f) {
dp[toss][sumIdx] = (dp[toss][sumIdx] + dp[toss - 1][sumIdx - f]) % MOD;
}

View file

@ -49,7 +49,6 @@ class RLEIterator {
}
/**
* Your RLEIterator object will be instantiated and called as such:
* RLEIterator obj = new RLEIterator(encoding);
* int param_1 = obj.next(n);
* Your RLEIterator object will be instantiated and called as such: RLEIterator obj = new
* RLEIterator(encoding); int param_1 = obj.next(n);
*/