Skip to content

Commit fc41736

Browse files
committed
Update again
1 parent 8a59777 commit fc41736

File tree

11 files changed

+191
-4
lines changed

11 files changed

+191
-4
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Large diffs are not rendered by default.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Definition for a binary tree node.
3+
* public class TreeNode {
4+
* int val;
5+
* TreeNode left;
6+
* TreeNode right;
7+
* TreeNode() {}
8+
* TreeNode(int val) { this.val = val; }
9+
* TreeNode(int val, TreeNode left, TreeNode right) {
10+
* this.val = val;
11+
* this.left = left;
12+
* this.right = right;
13+
* }
14+
* }
15+
*/
16+
class Solution {
17+
private List<Integer> output;
18+
private void helper(TreeNode curr) {
19+
if (curr == null)
20+
return;
21+
22+
output.add(curr.val);
23+
helper(curr.left);
24+
helper(curr.right);
25+
}
26+
public List<Integer> getAllElements(TreeNode root1, TreeNode root2) {
27+
output = new ArrayList<>();
28+
helper(root1);
29+
helper(root2);
30+
Collections.sort(output);
31+
32+
return output;
33+
}
34+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Definition for a binary tree node.
3+
* public class TreeNode {
4+
* int val;
5+
* TreeNode left;
6+
* TreeNode right;
7+
* TreeNode() {}
8+
* TreeNode(int val) { this.val = val; }
9+
* TreeNode(int val, TreeNode left, TreeNode right) {
10+
* this.val = val;
11+
* this.left = left;
12+
* this.right = right;
13+
* }
14+
* }
15+
*/
16+
class Solution {
17+
private void helper(TreeNode curr, Stack<Integer> stk) {
18+
if (curr == null) {
19+
return;
20+
}
21+
22+
if (curr.right != null) {
23+
helper(curr.right, stk);
24+
}
25+
26+
stk.add(curr.val);
27+
28+
if (curr.left != null) {
29+
helper(curr.left, stk);
30+
}
31+
}
32+
33+
public List<Integer> getAllElements(TreeNode root1, TreeNode root2) {
34+
Stack<Integer> one = new Stack<>();
35+
Stack<Integer> two = new Stack<>();
36+
37+
helper(root1, one);
38+
helper(root2, two);
39+
40+
List<Integer> output = new LinkedList<>();
41+
42+
while (!one.isEmpty() && !two.isEmpty()) {
43+
if (one.peek() < two.peek()) {
44+
output.add(one.pop());
45+
} else {
46+
output.add(two.pop());
47+
}
48+
}
49+
50+
while (!one.isEmpty()) {
51+
output.add(one.pop());
52+
}
53+
54+
while (!two.isEmpty()) {
55+
output.add(two.pop());
56+
}
57+
58+
return output;
59+
}
60+
}

my-submissions/m1641.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
int countVowelStrings(int n) {
2+
return (n + 4) * (n + 3) * (n + 2) * (n + 1) / 24;
3+
}

my-submissions/m1641.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution {
2+
public:
3+
int countVowelStrings(int n) {
4+
return (n + 4) * (n + 3) * (n + 2) * (n + 1) / 24;
5+
}
6+
};

my-submissions/m1641.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This is just stars and bars lol
2+
// n stars, 4 bars
3+
// n + 4 choose 4
4+
5+
class Solution {
6+
public int countVowelStrings(int n) {
7+
return (n + 4) * (n + 3) * (n + 2) * (n + 1) / 24;
8+
}
9+
}

my-submissions/m1669.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Definition for singly-linked list.
3+
* struct ListNode {
4+
* int val;
5+
* struct ListNode *next;
6+
* };
7+
*/
8+
9+
10+
struct ListNode* mergeInBetween(struct ListNode* list1, int a, int b, struct ListNode* list2){
11+
12+
struct ListNode* aMinusOne = list1;
13+
14+
for (int i = 0; i < a - 1; i++) {
15+
aMinusOne = aMinusOne->next;
16+
}
17+
18+
struct ListNode* bPlusOne = aMinusOne;
19+
20+
for (int i = a - 1; i <= b; i++) {
21+
bPlusOne = bPlusOne->next;
22+
}
23+
24+
aMinusOne->next = list2;
25+
26+
while (aMinusOne->next) {
27+
aMinusOne = aMinusOne->next;
28+
}
29+
30+
aMinusOne->next = bPlusOne;
31+
return list1;
32+
}

my-submissions/m2317.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
int maximumXOR(int* nums, int numsSize) {
2+
int output = 0;
3+
for (int i = 0; i < numsSize; i++) {
4+
output |= nums[i];
5+
}
6+
return output;
7+
}

my-submissions/m2317.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public:
3+
int maximumXOR(vector<int>& nums) {
4+
int output = 0;
5+
6+
for (int num : nums) {
7+
output |= num;
8+
}
9+
10+
return output;
11+
}
12+
};

my-submissions/m2317.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public int maximumXOR(int[] nums) {
3+
int output = 0;
4+
for (int num : nums) {
5+
output |= num;
6+
}
7+
8+
return output;
9+
}
10+
}

0 commit comments

Comments
 (0)