Skip to content

Commit 82404e1

Browse files
committed
new code added
1 parent 3b76477 commit 82404e1

18 files changed

+128
-5
lines changed

bin/Aug1/DuplicateWordFinder.class

1.3 KB
Binary file not shown.
821 Bytes
Binary file not shown.
837 Bytes
Binary file not shown.

bin/Aug1/Factorial.class

641 Bytes
Binary file not shown.

bin/Aug1/FibonnacciSeries.class

1016 Bytes
Binary file not shown.

bin/Aug1/FindTheDuplicateNumber.class

1.14 KB
Binary file not shown.

bin/Aug1/GreaterNumberInArray.class

927 Bytes
Binary file not shown.

bin/capgimini/CountOccurrences.class

14 Bytes
Binary file not shown.

bin/capgimini/Sortings.class

104 Bytes
Binary file not shown.

src/Aug1/DuplicateWordFinder.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package Aug1;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
public class DuplicateWordFinder {
7+
8+
public static void main(String[] args) {
9+
// TODO Auto-generated method stub
10+
String str = "masum,raza,masum,tata";
11+
String[] word = str.split(",");
12+
Set<String> uniqWord = new HashSet<>();
13+
for (String words : word) {
14+
uniqWord.add(words.trim());
15+
}
16+
for (String words : uniqWord) {
17+
System.out.println(words);
18+
}
19+
20+
}
21+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package Aug1;
2+
3+
public class EvenLetterPrintFromString {
4+
5+
public static void main(String[] args) {
6+
// TODO Auto-generated method stub
7+
String str = "masum";
8+
int count = 0;
9+
for (int i = 1; i <= str.length() - 1; i += 2) {
10+
count++;
11+
System.out.println(str.charAt(i));
12+
}
13+
System.out.println(count);
14+
}
15+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package Aug1;
2+
3+
public class ExtractSpecialCharacterFromString {
4+
5+
public static void main(String[] args) {
6+
// TODO Auto-generated method stub
7+
String str = "ma@$@$S@*@#U999768^&^&M{}}|R98765a876z9a";
8+
String rp = str.replaceAll("[^a-zA-Z]", "");
9+
System.out.println(rp);
10+
}
11+
}

src/Aug1/Factorial.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package Aug1;
2+
3+
public class Factorial {
4+
5+
public static void main(String[] args) {
6+
// TODO Auto-generated method stub
7+
int num = 5;
8+
long factorial = 1;
9+
for (int i = 1; i <= num; i++) {
10+
factorial = factorial * i;
11+
}
12+
System.out.println(factorial);
13+
}
14+
}

src/Aug1/FibonnacciSeries.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package Aug1;
2+
3+
public class FibonnacciSeries {
4+
5+
public static void main(String[] args) {
6+
// TODO Auto-generated method stub
7+
int n1 = 0, n2 = 1, sum;
8+
System.out.println(n1 + " " + n2);
9+
for (int i = 2; i <= 18; i++) {
10+
sum = n1 + n2;
11+
n1 = n2;
12+
n2 = sum;
13+
System.out.println(sum);
14+
}
15+
}
16+
}

src/Aug1/FindTheDuplicateNumber.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package Aug1;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
public class FindTheDuplicateNumber {
7+
8+
public static void main(String[] args) {
9+
// TODO Auto-generated method stub
10+
int arr[] = { 12, 23, 1, 43, 53, 64, 67, 78, 76, 65, 53, 32, 56, 77, 45, 75, 32, 1 };
11+
Set<Integer> uniq = new HashSet<>();
12+
Set<Integer> duplicate = new HashSet<>();
13+
for (int num : arr) {
14+
if (!uniq.add(num)) {
15+
duplicate.add(num);
16+
}
17+
}
18+
System.out.println(duplicate);
19+
}
20+
}

src/Aug1/GreaterNumberInArray.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package Aug1;
2+
3+
public class GreaterNumberInArray {
4+
5+
public static void main(String[] args) {
6+
// TODO Auto-generated method stub
7+
int arr[] = { 12, 23, 2, 43, 53, 64, 67, 100, 78, 76, 65, 53, 32, 56, 77, 45, 75, 32, 5 };
8+
int min = Integer.MAX_VALUE;
9+
int max = Integer.MIN_VALUE;
10+
for (int ele : arr) {
11+
if (max < ele) {
12+
max = ele;
13+
}
14+
if (min > ele) {
15+
min = ele;
16+
}
17+
}
18+
System.out.println(max);
19+
System.out.println(min);
20+
}
21+
}

src/capgimini/CountOccurrences.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public class CountOccurrences {
66
public static void main(String[] args) {
7-
String str = "hello";
7+
String str = "ABBCCCDDDDEEEEEFABC";
88
HashMap<Character, Integer> countMap = new HashMap<>();
99

1010
for (char c : str.toCharArray()) {

src/capgimini/Sortings.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package capgimini;
22

3+
import java.util.Arrays;
4+
35
public class Sortings {
46

57
public static void main(String[] args) {
6-
// TODO Auto-generated method stub
7-
String input = "mas12355@!$%#$|123456|}{{um }{}{MAS}{UM}{(*&*^&%^%$#ra@#$%za";
8-
String removedRegularExpression = input.replaceAll("[^a-zA-Z]", "");
9-
System.out.println(removedRegularExpression);
8+
int arr[] = { 34, 13, 9, 33, 57, 83, 2, 7, 8, 943, 45, 88, 4 };
9+
int brr[] = { 1, 36, 78, 84, 0, 66, 88, 3 };
10+
int combined[] = new int[arr.length + brr.length];
11+
System.arraycopy(arr, 0, combined, 0, arr.length);
12+
System.arraycopy(brr, 0, combined, arr.length, brr.length);
13+
Arrays.sort(combined);
14+
System.out.println(Arrays.toString(combined));
1015
}
1116
}

0 commit comments

Comments
 (0)