From 09628ff500c918814f92f2f8b750374dadfcb5c5 Mon Sep 17 00:00:00 2001 From: Nitish Raj <76819921+iamnitish17@users.noreply.github.com> Date: Fri, 28 Oct 2022 19:06:27 +0530 Subject: [PATCH 1/4] firstIndexOfNumber --- firstIndexOfNumber.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 firstIndexOfNumber.java diff --git a/firstIndexOfNumber.java b/firstIndexOfNumber.java new file mode 100644 index 0000000..78d00e8 --- /dev/null +++ b/firstIndexOfNumber.java @@ -0,0 +1,19 @@ + +public class firstIndexOfNumber { + + public static int fIndex(int input[], int x) { + + return fIndex(input,x,0); + } + public static int fIndex(int input[],int X,int sIndex){ + if(sIndex > input.length-1){ + return -1; + } + if(input[sIndex]==X){ + return sIndex; + } + int smallAns = fIndex(input,X,sIndex+1); + return smallAns; + } + +} \ No newline at end of file From 74c15c808fcee6e9b238d1a96ea92af3bb41f1b1 Mon Sep 17 00:00:00 2001 From: Nitish Raj <76819921+iamnitish17@users.noreply.github.com> Date: Sat, 29 Oct 2022 10:40:48 +0530 Subject: [PATCH 2/4] lastIndexOfNumber --- lastIndexOfNumber.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 lastIndexOfNumber.java diff --git a/lastIndexOfNumber.java b/lastIndexOfNumber.java new file mode 100644 index 0000000..3c24ded --- /dev/null +++ b/lastIndexOfNumber.java @@ -0,0 +1,24 @@ + +public class lastIndexOfNumber{ + + public static int lIndex(int input[], int x) { + + return lIndex(input,x,0); + } + public static int lIndex(int input[], int X, int sIndex){ + if(sIndex > input.length-1){ + return -1; + } + + int smallAns = lIndex(input,X,sIndex+1); + if(smallAns == -1){ + if(input[sIndex]==X){ + return sIndex; + }else{ + return -1; + } + }else{ + return smallAns; + } + } +} \ No newline at end of file From e0595cbd6792c48ab2e035f8242dd7de90ebc003 Mon Sep 17 00:00:00 2001 From: Nitish Raj <76819921+iamnitish17@users.noreply.github.com> Date: Sun, 30 Oct 2022 23:36:30 +0530 Subject: [PATCH 3/4] removeX-Recursion --- removeX.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 removeX.java diff --git a/removeX.java b/removeX.java new file mode 100644 index 0000000..16d005e --- /dev/null +++ b/removeX.java @@ -0,0 +1,18 @@ +public class solution { + + public static String removeX(String input){ + return removeX(input,0); + } + + public static String removeX(String input , int sIndex){ + if(sIndex == input.length()){ + return ""; + } + if(input.charAt(sIndex)=='x'){ + return removeX(input,sIndex+1); + } + String ans = input.charAt(sIndex) + removeX(input,sIndex+1); + return ans; + + } +} From 7c9f7699179a178aefbf664227a698fc074ac8d6 Mon Sep 17 00:00:00 2001 From: Nitish Raj <76819921+iamnitish17@users.noreply.github.com> Date: Sun, 30 Oct 2022 23:40:08 +0530 Subject: [PATCH 4/4] pairSumToZero-HashMap --- pairSumToZero.java | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pairSumToZero.java diff --git a/pairSumToZero.java b/pairSumToZero.java new file mode 100644 index 0000000..8a9ed93 --- /dev/null +++ b/pairSumToZero.java @@ -0,0 +1,31 @@ +import java.util.*; + +public class Solution { + + public static int PairSum(int[] input, int size) { + HashMap map = new HashMap<>(); + for(int i=0;i