Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fcca302

Browse filesBrowse files
committed
Added more solutions
1 parent 7829ff4 commit fcca302
Copy full SHA for fcca302

File tree

7 files changed

+110
-3
lines changed
Filter options

7 files changed

+110
-3
lines changed

‎LeetCodeSolutions/EasyLevelSolutions/.classpath

Copy file name to clipboardExpand all lines: LeetCodeSolutions/EasyLevelSolutions/.classpath
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<attribute name="maven.pomderived" value="true"/>
1313
</attributes>
1414
</classpathentry>
15-
<classpathentry kind="src" path="src/main/resources"/>
15+
<classpathentry kind="src" path="src/main/resources/sqls"/>
1616
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
1717
<attributes>
1818
<attribute name="maven.pomderived" value="true"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
*
3+
*/
4+
package com.javaaid.solutions.easy.arrays;
5+
6+
import java.util.Arrays;
7+
8+
/**
9+
* @author Kanahaiya Gupta
10+
*
11+
*/
12+
public class ArrayPartitionI {
13+
public int arrayPairSum(int[] nums) {
14+
Arrays.sort(nums);
15+
int sum=0;
16+
for(int i=0;i<nums.length;i=i+2) {
17+
sum+=nums[i];
18+
}
19+
return sum;
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
*
3+
*/
4+
package com.javaaid.solutions.easy.arrays;
5+
6+
/**
7+
* @author Kanahaiya Gupta
8+
*
9+
*/
10+
public class MergeTwoBinaryTrees {
11+
12+
static class TreeNode {
13+
int val;
14+
TreeNode left;
15+
TreeNode right;
16+
17+
TreeNode(int x) {
18+
val = x;
19+
}
20+
}
21+
22+
public TreeNode mergeTrees(TreeNode t1, TreeNode t2) {
23+
if (t1 == null)return t2;
24+
if (t2 == null)return t1;
25+
t1.val = t1.val + t2.val;
26+
t1.left = mergeTrees(t1.left, t2.left);
27+
t1.right = mergeTrees(t1.right, t2.right);
28+
return t1;
29+
}
30+
31+
public static void main(String[] args) {
32+
TreeNode t1 = new TreeNode(1);
33+
t1.left = new TreeNode(3);
34+
t1.right = new TreeNode(2);
35+
t1.left.left = new TreeNode(5);
36+
TreeNode t2 = new TreeNode(2);
37+
t2.left = new TreeNode(1);
38+
t2.right = new TreeNode(3);
39+
t2.left.right = new TreeNode(4);
40+
t2.right.right = new TreeNode(7);
41+
MergeTwoBinaryTrees obj = new MergeTwoBinaryTrees();
42+
obj.mergeTrees(t1, t2);
43+
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
*
3+
*/
4+
package com.javaaid.solutions.easy.arrays;
5+
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
9+
/**
10+
* @author Kanahaiya Gupta
11+
*
12+
*/
13+
public class SelfDividingNumbers {
14+
public List<Integer> selfDividingNumbers(int left, int right) {
15+
List<Integer> list=new ArrayList<Integer>();
16+
for(int i=left;i<=right;i++) {
17+
if(isSelfDivisible(i,i+"")) {
18+
list.add(i);
19+
}
20+
}
21+
22+
return list;
23+
24+
}
25+
26+
/**
27+
* @param i
28+
* @return
29+
*/
30+
private boolean isSelfDivisible(int n,String num) {
31+
if(num.indexOf('0')!=-1)return false;
32+
for(int i=0;i<num.length();i++) {
33+
char ch=num.charAt(i);
34+
int digit=ch-'0';
35+
if(n%digit!=0) {
36+
return false;
37+
}
38+
}
39+
return true;
40+
}
41+
}

‎LeetCodeSolutions/EasyLevelSolutions/src/main/java/com/javaaid/solutions/easy/arrays/HammingDistance.java renamed to ‎LeetCodeSolutions/EasyLevelSolutions/src/main/java/com/javaaid/solutions/easy/bitmanipulations/HammingDistance.java

Copy file name to clipboardExpand all lines: LeetCodeSolutions/EasyLevelSolutions/src/main/java/com/javaaid/solutions/easy/bitmanipulations/HammingDistance.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
*
33
*/
4-
package com.javaaid.solutions.easy.arrays;
4+
package com.javaaid.solutions.easy.bitmanipulations;
55

66
/**
77
* @author Kanahaiya Gupta
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
*
33
*/
4-
package com.javaaid.solutions.easy.arrays;
4+
package com.javaaid.solutions.easy.strings;
55

66
/**
77
* @author Kanahaiya Gupta

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.