Skip to content

Commit 6faa690

Browse files
committed
Corrected line endings from CRLF to LF
1 parent 5936f74 commit 6faa690

File tree

13 files changed

+509
-509
lines changed

13 files changed

+509
-509
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
package com.fishercoder.solutions.firstthousand;
2-
3-
import com.fishercoder.common.classes.TreeNode;
4-
5-
public class _100 {
6-
public static class Solution1 {
7-
public boolean isSameTree(TreeNode p, TreeNode q) {
8-
if (p == null || q == null) {
9-
return p == q;
10-
}
11-
return p.val == q.val && isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
12-
}
13-
}
14-
}
1+
package com.fishercoder.solutions.firstthousand;
2+
3+
import com.fishercoder.common.classes.TreeNode;
4+
5+
public class _100 {
6+
public static class Solution1 {
7+
public boolean isSameTree(TreeNode p, TreeNode q) {
8+
if (p == null || q == null) {
9+
return p == q;
10+
}
11+
return p.val == q.val && isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
12+
}
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
package com.fishercoder.solutions.firstthousand;
2-
3-
import com.fishercoder.common.classes.TreeNode;
4-
5-
public class _101 {
6-
public static class Solution1 {
7-
public boolean isSymmetric(TreeNode root) {
8-
if (root == null) {
9-
return true;
10-
}
11-
return isSymmetric(root.left, root.right);
12-
}
13-
14-
private boolean isSymmetric(TreeNode left, TreeNode right) {
15-
if (left == null || right == null) {
16-
return left == right;
17-
}
18-
return left.val == right.val
19-
&& isSymmetric(left.left, right.right)
20-
&& isSymmetric(left.right, right.left);
21-
}
22-
}
23-
24-
public static class Solution2 {
25-
/** The same as the above solution, just a bit more verbose. */
26-
public boolean isSymmetric(TreeNode root) {
27-
if (root == null) {
28-
return true;
29-
}
30-
return isSymmetric(root.left, root.right);
31-
}
32-
33-
private boolean isSymmetric(TreeNode left, TreeNode right) {
34-
if (left == null && right == null) {
35-
return true;
36-
} else if (left == null || right == null) {
37-
return false;
38-
}
39-
if (left.val == right.val) {
40-
return isSymmetric(left.left, right.right) && isSymmetric(left.right, right.left);
41-
} else {
42-
return false;
43-
}
44-
}
45-
}
46-
}
1+
package com.fishercoder.solutions.firstthousand;
2+
3+
import com.fishercoder.common.classes.TreeNode;
4+
5+
public class _101 {
6+
public static class Solution1 {
7+
public boolean isSymmetric(TreeNode root) {
8+
if (root == null) {
9+
return true;
10+
}
11+
return isSymmetric(root.left, root.right);
12+
}
13+
14+
private boolean isSymmetric(TreeNode left, TreeNode right) {
15+
if (left == null || right == null) {
16+
return left == right;
17+
}
18+
return left.val == right.val
19+
&& isSymmetric(left.left, right.right)
20+
&& isSymmetric(left.right, right.left);
21+
}
22+
}
23+
24+
public static class Solution2 {
25+
/** The same as the above solution, just a bit more verbose. */
26+
public boolean isSymmetric(TreeNode root) {
27+
if (root == null) {
28+
return true;
29+
}
30+
return isSymmetric(root.left, root.right);
31+
}
32+
33+
private boolean isSymmetric(TreeNode left, TreeNode right) {
34+
if (left == null && right == null) {
35+
return true;
36+
} else if (left == null || right == null) {
37+
return false;
38+
}
39+
if (left.val == right.val) {
40+
return isSymmetric(left.left, right.right) && isSymmetric(left.right, right.left);
41+
} else {
42+
return false;
43+
}
44+
}
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
package com.fishercoder.solutions.firstthousand;
2-
3-
import com.fishercoder.common.classes.TreeNode;
4-
import java.util.ArrayList;
5-
import java.util.LinkedList;
6-
import java.util.List;
7-
import java.util.Queue;
8-
9-
public class _102 {
10-
11-
public static class Solution1 {
12-
public List<List<Integer>> levelOrder(TreeNode root) {
13-
List<List<Integer>> result = new ArrayList<>();
14-
if (root == null) {
15-
return result;
16-
}
17-
Queue<TreeNode> queue = new LinkedList();
18-
queue.offer(root);
19-
while (!queue.isEmpty()) {
20-
List<Integer> thisLevel = new ArrayList();
21-
int size = queue.size();
22-
for (int i = 0; i < size; i++) {
23-
TreeNode curr = queue.poll();
24-
thisLevel.add(curr.val);
25-
if (curr.left != null) {
26-
queue.offer(curr.left);
27-
}
28-
if (curr.right != null) {
29-
queue.offer(curr.right);
30-
}
31-
}
32-
result.add(thisLevel);
33-
}
34-
return result;
35-
}
36-
}
37-
}
1+
package com.fishercoder.solutions.firstthousand;
2+
3+
import com.fishercoder.common.classes.TreeNode;
4+
import java.util.ArrayList;
5+
import java.util.LinkedList;
6+
import java.util.List;
7+
import java.util.Queue;
8+
9+
public class _102 {
10+
11+
public static class Solution1 {
12+
public List<List<Integer>> levelOrder(TreeNode root) {
13+
List<List<Integer>> result = new ArrayList<>();
14+
if (root == null) {
15+
return result;
16+
}
17+
Queue<TreeNode> queue = new LinkedList();
18+
queue.offer(root);
19+
while (!queue.isEmpty()) {
20+
List<Integer> thisLevel = new ArrayList();
21+
int size = queue.size();
22+
for (int i = 0; i < size; i++) {
23+
TreeNode curr = queue.poll();
24+
thisLevel.add(curr.val);
25+
if (curr.left != null) {
26+
queue.offer(curr.left);
27+
}
28+
if (curr.right != null) {
29+
queue.offer(curr.right);
30+
}
31+
}
32+
result.add(thisLevel);
33+
}
34+
return result;
35+
}
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
package com.fishercoder.solutions.firstthousand;
2-
3-
import com.fishercoder.common.classes.TreeNode;
4-
import java.util.ArrayList;
5-
import java.util.Collections;
6-
import java.util.LinkedList;
7-
import java.util.List;
8-
import java.util.Queue;
9-
10-
public class _107 {
11-
public static class Solution1 {
12-
public List<List<Integer>> levelOrderBottom(TreeNode root) {
13-
List<List<Integer>> result = new ArrayList();
14-
if (root == null) {
15-
return result;
16-
}
17-
Queue<TreeNode> q = new LinkedList();
18-
q.offer(root);
19-
while (!q.isEmpty()) {
20-
List<Integer> thisLevel = new ArrayList<>();
21-
int qSize = q.size();
22-
for (int i = 0; i < qSize; i++) {
23-
TreeNode curr = q.poll();
24-
thisLevel.add(curr.val);
25-
if (curr.left != null) {
26-
q.offer(curr.left);
27-
}
28-
if (curr.right != null) {
29-
q.offer(curr.right);
30-
}
31-
}
32-
result.add(thisLevel);
33-
}
34-
Collections.reverse(result);
35-
return result;
36-
}
37-
}
38-
}
1+
package com.fishercoder.solutions.firstthousand;
2+
3+
import com.fishercoder.common.classes.TreeNode;
4+
import java.util.ArrayList;
5+
import java.util.Collections;
6+
import java.util.LinkedList;
7+
import java.util.List;
8+
import java.util.Queue;
9+
10+
public class _107 {
11+
public static class Solution1 {
12+
public List<List<Integer>> levelOrderBottom(TreeNode root) {
13+
List<List<Integer>> result = new ArrayList();
14+
if (root == null) {
15+
return result;
16+
}
17+
Queue<TreeNode> q = new LinkedList();
18+
q.offer(root);
19+
while (!q.isEmpty()) {
20+
List<Integer> thisLevel = new ArrayList<>();
21+
int qSize = q.size();
22+
for (int i = 0; i < qSize; i++) {
23+
TreeNode curr = q.poll();
24+
thisLevel.add(curr.val);
25+
if (curr.left != null) {
26+
q.offer(curr.left);
27+
}
28+
if (curr.right != null) {
29+
q.offer(curr.right);
30+
}
31+
}
32+
result.add(thisLevel);
33+
}
34+
Collections.reverse(result);
35+
return result;
36+
}
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
package com.fishercoder.solutions.firstthousand;
2-
3-
import com.fishercoder.common.classes.ListNode;
4-
import java.util.HashSet;
5-
import java.util.Set;
6-
7-
public class _141 {
8-
9-
public static class Solution1 {
10-
public boolean hasCycle(ListNode head) {
11-
Set<ListNode> set = new HashSet();
12-
while (head != null) {
13-
if (!set.add(head)) {
14-
return true;
15-
}
16-
head = head.next;
17-
}
18-
return false;
19-
}
20-
}
21-
22-
public static class Solution2 {
23-
public boolean hasCycle(ListNode head) {
24-
ListNode slow = head;
25-
ListNode fast = head;
26-
while (fast != null && fast.next != null) {
27-
fast = fast.next.next;
28-
slow = slow.next;
29-
if (fast == slow) {
30-
return true;
31-
}
32-
}
33-
return false;
34-
}
35-
}
36-
}
1+
package com.fishercoder.solutions.firstthousand;
2+
3+
import com.fishercoder.common.classes.ListNode;
4+
import java.util.HashSet;
5+
import java.util.Set;
6+
7+
public class _141 {
8+
9+
public static class Solution1 {
10+
public boolean hasCycle(ListNode head) {
11+
Set<ListNode> set = new HashSet();
12+
while (head != null) {
13+
if (!set.add(head)) {
14+
return true;
15+
}
16+
head = head.next;
17+
}
18+
return false;
19+
}
20+
}
21+
22+
public static class Solution2 {
23+
public boolean hasCycle(ListNode head) {
24+
ListNode slow = head;
25+
ListNode fast = head;
26+
while (fast != null && fast.next != null) {
27+
fast = fast.next.next;
28+
slow = slow.next;
29+
if (fast == slow) {
30+
return true;
31+
}
32+
}
33+
return false;
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)