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
30 changes: 30 additions & 0 deletions Hackerrank/Hashmap.java
Original file line number Diff line number Diff line change
@@ -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<String, Integer> map = new HashMap<String, Integer>();
for(int i=0;i<n;i++)
{
String name = x.next();
int phone = x.nextInt();
x.nextLine();
map.put(name, phone);
}
while(x.hasNext())
{
String s=x.nextLine();
if (map.get(s) != null) {
System.out.println(s+"="+map.get(s));
} else {
System.out.println("Not found");
}
}
}
}
35 changes: 35 additions & 0 deletions Hackerrank/Review.java
Original file line number Diff line number Diff line change
@@ -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<n;i++)
strings[i]=x.nextLine();
for(int i = 0;i < n;i++){
String word = strings[i];
ArrayList<Integer> 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();
}
}}