Skip to content

add test 606 #7

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
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/main/java/com/fishercoder/solutions/_396.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,27 @@ private int[] rotate(int[] a) {
a[a.length-1] = first;
return a;
}
//**credit : https://discuss.leetcode.com/topic/58459/java-o-n-solution-with-explanation
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave a blank line in between different functions.

public int maxRotateFunction_1(int[] A) {
int allSum = 0;
int len = A.length;
int F = 0;
for (int i = 0; i < len; i++) {
F += i * A[i];
allSum += A[i];
}
int max = F;
for (int i = len - 1; i >= 1; i--) {
F = F + allSum - len * A[i];
max = Math.max(F, max);
}
return max;
}

public static void main(String...strings){
int[] nums = new int[]{4, 3, 2, 6};
_396 test = new _396();
System.out.println(test.maxRotateFunction(nums));
System.out.println(test.maxRotateFunction_1(nums));
}
}
8 changes: 8 additions & 0 deletions src/test/java/com/fishercoder/_606Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ public void test2(){
System.out.println("Test2");
assertEquals("1(2()(4))(3)", test.tree2str(t));
}
@Test
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave a blank line between tests please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, each time when I PR for a file and I need to close it for the second file that I want to PR?

public void test3(){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a space between () and {, or you could always select all and format all before you submit a PR.

t= new TreeNode(1);
t.right = new TreeNode(2);
t.right.right = new TreeNode(3);
System.out.println("Test3");
assertEquals("1()(2()(3))", test.tree2str(t));
}
}