From ebedcaf11e552022b39b654efc5938fbb20fed68 Mon Sep 17 00:00:00 2001 From: Afraj <60289125+afraj18@users.noreply.github.com> Date: Sat, 16 Oct 2021 16:05:07 +0530 Subject: [PATCH 1/4] unnecessary class file deleted --- Recursive.class | Bin 1172 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Recursive.class diff --git a/Recursive.class b/Recursive.class deleted file mode 100644 index 68173fbe8cd1cd34eb59bd560ec36ab94573b490..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1172 zcmaJ=-A)rh6#k|y-FDd)0r{&`7X@uWssA7aR2qq!6g8Gej5iML2uruS&F(CbH}T3R z;6^UMVB!P#P{uQDV~Y?kcIM34?|kR~*YDGx02Z*O!@#(Pi6k<(q9cMyC1n%1s^c0= zrJ2&vkLyE(zp3Gth8#nD*>-KY$`H-v-!a5WUQI9zlx9?X9`hmSK z<`t8H6w(ZXE!I%lPN7oet}A>Ec>}YUQ-IqB?qHtb(hFA#-{fXHwk1*^e|66Iz6`!T$ z5;L{T(y@pq3|A{*!}LCxa#xsv@NE&8VbheJ$xJ&i8N*nE*G0*5t6Xl`a+jn)a#seb zrIwXH-&74ts$eu3)7>K3?!H$SoxZo()_GNW{(**PG)!gBtA|Yn!%`hAIXnmix%kqX zN{6G}o0r_JIU<;D8y3%p(W5zIxOvbN7r=X`v)$2RZ*Com5_g=6Ek#kobB397`CSwn z)%gE7Own=~v|B(Fv;#=fIY6&0-Hh(O*%PpDB+!u28E+|LNMaB}BrE6^na1dz`+>;& zBScRSD<7e6D1HoW?ih)c$?r(6l4de{3LPMImoP(=inbpKT7)FVNy<`0vlL5GtwzVm zVk=f}h7AsI(nk);U$l42BDip)mnMJc7|7;S;ZutK*^d__FPGA3|? L-U)h7(>L=6hnpG1 From ca11b84882924071b1064b673f93f02161e78654 Mon Sep 17 00:00:00 2001 From: Afraj <60289125+afraj18@users.noreply.github.com> Date: Sat, 16 Oct 2021 16:12:42 +0530 Subject: [PATCH 2/4] DSA with Java some new files updated HashMap and Binary Tree Files Added --- Java/binaryTreeCustom.java | 39 ++++++++++++++++++++++++++++++++++++++ Java/indicesOfTwo.java | 27 ++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 Java/binaryTreeCustom.java create mode 100644 Java/indicesOfTwo.java diff --git a/Java/binaryTreeCustom.java b/Java/binaryTreeCustom.java new file mode 100644 index 0000000..7fc3915 --- /dev/null +++ b/Java/binaryTreeCustom.java @@ -0,0 +1,39 @@ +package com.company; + +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; + } +} diff --git a/Java/indicesOfTwo.java b/Java/indicesOfTwo.java new file mode 100644 index 0000000..10ccb46 --- /dev/null +++ b/Java/indicesOfTwo.java @@ -0,0 +1,27 @@ +package com.company; + +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 hm = new HashMap( ); + + 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))); + } +} \ No newline at end of file From e6c0bc9acc24a85e7e066531eed3be6cbf093f7a Mon Sep 17 00:00:00 2001 From: Afraj <60289125+afraj18@users.noreply.github.com> Date: Sun, 17 Oct 2021 12:28:26 +0530 Subject: [PATCH 3/4] requested change is made --- Java/binaryTreeCustom.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/Java/binaryTreeCustom.java b/Java/binaryTreeCustom.java index 7fc3915..129be38 100644 --- a/Java/binaryTreeCustom.java +++ b/Java/binaryTreeCustom.java @@ -1,5 +1,3 @@ -package com.company; - public class binaryTreeCustom { public static void main(String[] args) { Node n1 = new Node(5); From 352e5a952de2172ccf132c2b7fa0825d19cc808e Mon Sep 17 00:00:00 2001 From: Afraj <60289125+afraj18@users.noreply.github.com> Date: Sun, 17 Oct 2021 12:29:22 +0530 Subject: [PATCH 4/4] requested change in this file is made --- Java/indicesOfTwo.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Java/indicesOfTwo.java b/Java/indicesOfTwo.java index 10ccb46..a65fdb6 100644 --- a/Java/indicesOfTwo.java +++ b/Java/indicesOfTwo.java @@ -1,5 +1,3 @@ -package com.company; - import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -24,4 +22,4 @@ public static void main(String[] args) throws IllegalAccessException { indicesOfTwo ts = new indicesOfTwo(); System.out.println(Arrays.toString(ts.sumTwo(myarr, 26))); } -} \ No newline at end of file +}