Skip to content
Open
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
37 changes: 37 additions & 0 deletions Java/binaryTreeCustom.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
public class binaryTreeCustom {
public static void main(String[] args) {
Node n1 = new Node(5);
Node n2 = new Node(3);
Node n3 = new Node(2);
Node n4 = new Node(32);
Node n5 = new Node(23);
Node n6 = new Node(52);


n1.left = n2;
n1.right = n3;
n2.left = n4;
n2.right = n5;
n3.left = n6;
// n1.right = n5;

System.out.println(sumvalue(n1));

}
public static int sumvalue(Node root){
if (root==null){
return 0;
}
return root.data+sumvalue(root.left)+sumvalue(root.right);

}
}
class Node {
int data;
Node left;
Node right;

Node(int data){
this.data = data;
}
}
25 changes: 25 additions & 0 deletions Java/indicesOfTwo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class indicesOfTwo {
public int[] sumTwo(int[] nums_arr, int target) throws IllegalAccessException {
HashMap<Integer, Integer> hm = new HashMap<Integer,Integer>( );

for (int i = 0; i < nums_arr.length; i++) {
int comp = target - nums_arr[i];
if (hm.containsKey(comp)) {
return new int[] {hm.get(comp), i};
}
hm.put(nums_arr[i],i);
}
throw new IllegalAccessException("Not Found");
}


public static void main(String[] args) throws IllegalAccessException {
int myarr[] = {2, 7,11,15};
indicesOfTwo ts = new indicesOfTwo();
System.out.println(Arrays.toString(ts.sumTwo(myarr, 26)));
}
}
Binary file removed Recursive.class
Binary file not shown.