-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a98d632
commit acc5632
Showing
10 changed files
with
125 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/interview_Coding_Questions/CheckStringAnagrams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package interview_Coding_Questions; | ||
|
||
import java.util.Objects; | ||
import java.util.Scanner; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public class CheckStringAnagrams { | ||
static String r; | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); | ||
String c; | ||
|
||
do { | ||
System.out.println("enter string 1 :"); | ||
String a = scanner.next(); | ||
System.out.println("enter string 1 :"); | ||
String b = scanner.next(); | ||
String result = isAnagram(a, b); | ||
System.out.println(result); | ||
System.out.println("do you want to continue : (y/n)"); | ||
c = scanner.next(); | ||
|
||
|
||
} while (!Objects.equals(c, "n")); | ||
|
||
|
||
} | ||
public static String isAnagram(String a,String b){ | ||
a= Stream.of(a.split("")).map(String::toUpperCase).sorted().collect(Collectors.joining()); | ||
b= Stream.of(b.split("")).map(String::toUpperCase).sorted().collect(Collectors.joining()); | ||
if (a.equals(b)){ | ||
r= "this is anagram"; | ||
}else { | ||
r="this is not anagram"; | ||
} | ||
return r; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
src/main/java/interview_Coding_Questions/MaxMinInList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package interview_Coding_Questions; | ||
|
||
import java.util.Arrays; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class MaxMinInList { | ||
public static void main(String[] args) { | ||
List<Integer>list = Arrays.asList(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20); | ||
int max = list.stream().max(Comparator.naturalOrder()).get(); | ||
int min = list.stream().min(Comparator.naturalOrder()).get(); | ||
|
||
System.out.println("\nOriginal list is :\n"+list); | ||
System.out.println("max ix : "+max); | ||
System.out.println("min ix : "+min); | ||
|
||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/interview_Coding_Questions/Merge_Two_Unsorted_Array.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package interview_Coding_Questions; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.IntStream; | ||
|
||
public class Merge_Two_Unsorted_Array { | ||
public static void main(String[] args) { | ||
// How do you merge two unsorted arrays into single sorted array using Java 8 streams? | ||
|
||
int[] a =new int[]{11,23,43}; | ||
int[] b =new int[]{99,78,1,2}; | ||
|
||
System.out.println("\noriginal array a is :\n"+Arrays.toString(a)); | ||
System.out.println("\noriginal array b is :\n"+Arrays.toString(b)); | ||
|
||
|
||
int[] c = IntStream.concat(Arrays.stream(a),Arrays.stream(b)).sorted().toArray(); | ||
|
||
System.out.println("\n\nafter merging two array : "+Arrays.toString(c)); | ||
|
||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/interview_Coding_Questions/MultiplesOf5.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package interview_Coding_Questions; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class MultiplesOf5 { | ||
public static void main(String[] args) { | ||
List<Integer> list = Arrays.asList(14,15,16,4,5,10,55,550,789,43,23); | ||
System.out.println("original list\n"+list); | ||
System.out.println(); | ||
System.out.println("list of number are divalent by 5"); | ||
list.stream().filter(n->n%5==0).forEach(System.out::println); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/interview_Coding_Questions/get3MaxMinNumbers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package interview_Coding_Questions; | ||
|
||
import java.util.Arrays; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class get3MaxMinNumbers { | ||
public static void main(String[] args) { | ||
List<Integer>list= Arrays.asList(45, 12, 56, 15, 24, 75, 31, 89); | ||
System.out.println("\nOriginal list is \n"+list+"\n"); | ||
System.out.println("\nfirst 3 minimum numbers in list :"); | ||
list.stream().distinct().sorted().limit(3).forEach(System.out::println); | ||
|
||
System.out.println("\nfirst 3 maximum numbers in list:"); | ||
list.stream().distinct().sorted(Comparator.reverseOrder()).limit(3).forEach(System.out::println); | ||
|
||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.