From e3218ce6189a310ece69b0c846efb153eb97f3bc Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 4 Oct 2019 21:23:29 +0530 Subject: [PATCH 1/4] Add hackerrank problem on Hashmap to Contributors list --- Hackerrank/Hashmap.java | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Hackerrank/Hashmap.java diff --git a/Hackerrank/Hashmap.java b/Hackerrank/Hashmap.java new file mode 100644 index 0000000..4b81693 --- /dev/null +++ b/Hackerrank/Hashmap.java @@ -0,0 +1,30 @@ + +//Complete this code or write your own from scratch +import java.util.*; +import java.io.*; + +class Hashmap{ + public static void main(String []argh) + { + Scanner x = new Scanner(System.in); + int n=x.nextInt(); + x.nextLine(); + Map map = new HashMap(); + for(int i=0;i Date: Fri, 4 Oct 2019 21:28:42 +0530 Subject: [PATCH 2/4] Add hackerrank problem on print odd and even characters to Contributors list --- Hackerrank/Review.java | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Hackerrank/Review.java diff --git a/Hackerrank/Review.java b/Hackerrank/Review.java new file mode 100644 index 0000000..32127eb --- /dev/null +++ b/Hackerrank/Review.java @@ -0,0 +1,35 @@ + import java.io.*; +import java.util.*; +import java.text.*; +import java.math.*; +import java.util.regex.*; +import java.lang.Iterable.*; + +public class Review { +//code to print odd and even numbers separetely + public static void main(String[] args) { + /*Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ + Scanner x=new Scanner(System.in); + int n=x.nextInt(); + x.nextLine(); + String strings[]=new String[100] ; + for(int i=0;i oddIndexes = new ArrayList<>(100); + for(int j= 0; j < word.length();j++){ + if(j % 2 == 0){ + System.out.print(word.charAt(j)); + }else{ + oddIndexes.add(j); + } + } + System.out.print(" "); + for(Integer index : oddIndexes){ + System.out.print(word.charAt(index)); + } + System.out.println(); + } + }} + From c4be1965d93e90a596b5c8d88a2f5a7ac04d00c4 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 4 Oct 2019 21:41:20 +0530 Subject: [PATCH 3/4] Add Solve me first to Contributions --- Hackerrank/First.java | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Hackerrank/First.java diff --git a/Hackerrank/First.java b/Hackerrank/First.java new file mode 100644 index 0000000..3c9118b --- /dev/null +++ b/Hackerrank/First.java @@ -0,0 +1,28 @@ + import java.io.*; +import java.util.*; +import java.text.*; +import java.math.*; +import java.util.regex.*; + +public class Solution { +//This is a practice problem from hackerrank solve me first + + + static int solveMeFirst(int a, int b) { + // Hint: Type return a+b; below + + } + + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + int a; + a = in.nextInt(); + int b; + b = in.nextInt(); + int sum; + sum = solveMeFirst(a, b); + System.out.println(sum); + } +} + + From e6ff660280d54414410bc4db5fac5fd6d6a3c0dd Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 4 Oct 2019 21:46:03 +0530 Subject: [PATCH 4/4] Added Simple 1D array practice problem --- Hackerrank/Simplearray.java | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Hackerrank/Simplearray.java diff --git a/Hackerrank/Simplearray.java b/Hackerrank/Simplearray.java new file mode 100644 index 0000000..b5b4897 --- /dev/null +++ b/Hackerrank/Simplearray.java @@ -0,0 +1,43 @@ + +import java.io.*; +import java.math.*; +import java.text.*; +import java.util.*; +import java.util.regex.*; + +public class Simplearray { + + /* + * Complete the simpleArraySum function below. + */ + static int simpleArraySum(int[] ar) { + /* + * Write your code here. + */ + + } + + private static final Scanner scanner = new Scanner(System.in); + + public static void main(String[] args) throws IOException { + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); + + int arCount = Integer.parseInt(scanner.nextLine().trim()); + + int[] ar = new int[arCount]; + + String[] arItems = scanner.nextLine().split(" "); + + for (int arItr = 0; arItr < arCount; arItr++) { + int arItem = Integer.parseInt(arItems[arItr].trim()); + ar[arItr] = arItem; + } + + int result = simpleArraySum(ar); + + bufferedWriter.write(String.valueOf(result)); + bufferedWriter.newLine(); + + bufferedWriter.close(); + } +}