diff --git a/src/test/java/March/DuplicateWordFinder.java b/src/test/java/March/DuplicateWordFinder.java new file mode 100644 index 0000000..cd67624 --- /dev/null +++ b/src/test/java/March/DuplicateWordFinder.java @@ -0,0 +1,18 @@ +package March; + +import java.util.HashSet; +import java.util.Set; + +public class DuplicateWordFinder { + public static void main(String[] args) { + String str = "masum raza delhi patna bihar delhi amnour delhi patn"; + String words[] = str.split(" "); + Set uniq = new HashSet(); + for (String word : words) { + uniq.add(word.trim()); + } + for (String word : uniq) { + System.out.println(word); + } + } +} diff --git a/src/test/java/March/EvenLetterPrintFromString.java b/src/test/java/March/EvenLetterPrintFromString.java new file mode 100644 index 0000000..0f3ab98 --- /dev/null +++ b/src/test/java/March/EvenLetterPrintFromString.java @@ -0,0 +1,19 @@ +package March; + +public class EvenLetterPrintFromString { + public static void main(String[] args) { + String str = "masumrazadelhi"; + + // Remove spaces completely + str = str.replace(" ", ""); + + // Now count only characters + for (int i = 0; i < str.length(); i++) { + if (i % 2 == 0) { // even position among letters + System.out.print(str.charAt(i) + " "); + } + } + } +} + +//m s m a a e h \ No newline at end of file diff --git a/src/test/java/March/SumOfNumber.java b/src/test/java/March/SumOfNumber.java new file mode 100644 index 0000000..7b66574 --- /dev/null +++ b/src/test/java/March/SumOfNumber.java @@ -0,0 +1,17 @@ +package March; + +public class SumOfNumber { + public static void main(String[] args) { + int num = 00; + while (num >= 10) { + int sum = 0; + while (num > 0) { + sum += num % 10; + num = num / 10; + } + num = sum; + } + System.out.println(num); + } + +} diff --git a/src/test/java/codeWithLogicExplanation/FindTheDuplicateNumber.java b/src/test/java/codeWithLogicExplanation/FindTheDuplicateNumber.java new file mode 100644 index 0000000..63ae404 --- /dev/null +++ b/src/test/java/codeWithLogicExplanation/FindTheDuplicateNumber.java @@ -0,0 +1,50 @@ +package codeWithLogicExplanation; + +import java.util.HashSet; +import java.util.Set; + +public class FindTheDuplicateNumber { + + public static void main(String[] args) { + + // Integer array with some duplicate values (747 appears multiple times) + int ar[] = { 133, 2, 134, 53554, 747, 747, 43634, 747, 86, 346 }; + + // Input string converted to lowercase for uniform comparison + String input = "India Delhi".toLowerCase(); + + // Set to store duplicate numbers + Set duplicate = new HashSet<>(); + + // Set to store unique numbers + Set uniq = new HashSet<>(); + + // Loop through each number in the array + for (int num : ar) { + // If adding to uniq fails (already exists), add to duplicate + if (!uniq.add(num)) { + duplicate.add(num); + } + } + + // Print duplicate numbers + System.out.println("duplicate number is : " + duplicate); + + // Set to store unique characters + Set uniqs = new HashSet<>(); + + // Set to store duplicate characters + Set duplicates = new HashSet<>(); + + // Loop through each character in the string + for (char c : input.toCharArray()) { + // If adding to uniqs fails (already exists), add to duplicates + if (!uniqs.add(c)) { + duplicates.add(c); + } + } + + // Print duplicate characters + System.out.println("duplicate charater is : " + duplicates); + } +} \ No newline at end of file diff --git a/src/test/java/codeWithLogicExplanation/NonRepeatingCharacter.java b/src/test/java/codeWithLogicExplanation/NonRepeatingCharacter.java new file mode 100644 index 0000000..a1fa268 --- /dev/null +++ b/src/test/java/codeWithLogicExplanation/NonRepeatingCharacter.java @@ -0,0 +1,30 @@ +package codeWithLogicExplanation; + +public class NonRepeatingCharacter { + + public static void main(String arg[]) { + + // Input string + String input = "masum raza delhi bihar"; + System.out.print("non repeating character is : "); + // Loop through each character + for (char c : input.toCharArray()) { + // If first and last occurrence of the character are the same, + // it means the character appears only once in the string + if (input.indexOf(c) == (input.lastIndexOf(c))) { + System.out.print(c + " "); + } + } + // Another string to check repeating characters + String sc = "bittumasum"; + System.out.print("\nrepeating character is: "); + // Loop through each character + for (char d : sc.toCharArray()) { + // If first and last occurrence are different, + // it means the character appears more than once + if (sc.indexOf(d) != (sc.lastIndexOf(d))) { + System.out.print(d + " "); + } + } + } +} \ No newline at end of file diff --git a/src/test/java/codeWithLogicExplanation/PalindromNumber.java b/src/test/java/codeWithLogicExplanation/PalindromNumber.java new file mode 100644 index 0000000..0e2d2b1 --- /dev/null +++ b/src/test/java/codeWithLogicExplanation/PalindromNumber.java @@ -0,0 +1,24 @@ +package codeWithLogicExplanation; + +public class PalindromNumber { + + public static void main(String[] args) { + + int num = 12321; // The number to check + int rev = 0; // Variable to store the reversed number + int original = num; // Keep a copy of the original number + + // Reverse the number + while (num != 0) { + rev = rev * 10 + num % 10; // Take last digit and build reversed number + num = num / 10; // Remove last digit from num + } + + // Compare original with reversed + if (original == rev) { + System.out.println(original + " number is palindrome"); + } else { + System.out.println(rev + " num is not palindrome"); + } + } +} \ No newline at end of file diff --git a/src/test/java/codeWithLogicExplanation/ReversString.java b/src/test/java/codeWithLogicExplanation/ReversString.java new file mode 100644 index 0000000..1991027 --- /dev/null +++ b/src/test/java/codeWithLogicExplanation/ReversString.java @@ -0,0 +1,19 @@ +package codeWithLogicExplanation; + +public class ReversString { + + public static void main(String[] args) { + + String input = "delhi"; // The original string + String rev = ""; // Variable to store the reversed string + int len = input.length(); // Get the length of the string (5 for "delhi") + + // Loop backwards from last character to first + for (int i = len - 1; i >= 0; i--) { + rev = rev + input.charAt(i); // Append each character to rev + } + + // Print the reversed string + System.out.println("reverse string is : " + rev); + } +} \ No newline at end of file diff --git a/src/test/java/codeWithLogicExplanation/SumOfNumber.java b/src/test/java/codeWithLogicExplanation/SumOfNumber.java new file mode 100644 index 0000000..1507dac --- /dev/null +++ b/src/test/java/codeWithLogicExplanation/SumOfNumber.java @@ -0,0 +1,24 @@ +package codeWithLogicExplanation; // Declares the package name (March). Helps organize classes. + +public class SumOfNumber { // Defines the class SumOfNumber + public static void main(String[] args) { // Main method: program entry point + int num = 9876; // Initialize the number you want to process (example: 9876) + + // Outer loop: keep running until num becomes a single digit (<= 9) + while (num > 9) { + int sum = 0; // Reset sum for this iteration + + // Inner loop: calculate sum of digits of num + while (num > 0) { + sum += num % 10; // Add last digit to sum + num = num / 10; // Remove last digit from num + } + + // After summing digits, assign sum back to num + num = sum; + } + + // Print the final single-digit result + System.out.println(num); + } +} \ No newline at end of file diff --git a/src/test/java/codeWithLogicExplanation/UpperCaseCountInString.java b/src/test/java/codeWithLogicExplanation/UpperCaseCountInString.java new file mode 100644 index 0000000..7c98803 --- /dev/null +++ b/src/test/java/codeWithLogicExplanation/UpperCaseCountInString.java @@ -0,0 +1,29 @@ +package codeWithLogicExplanation; + +public class UpperCaseCountInString { + + public static void main(String[] args) { + + // Input string to check + String input = "MaDhUBani"; + + // Counter to keep track of uppercase letters + int count = 0; + + // Loop through each character in the string + for (int i = 0; i <= input.length() - 1; i++) { + + // Get the character at position i + char c = input.charAt(i); + + // Check if the character is uppercase + if (Character.isUpperCase(c)) { + count++; // Increase count if uppercase + System.out.println("Upper character is : " + c); + } + } + + // Print total number of uppercase characters found + System.out.println("Total Upper case is : " + count); + } +} \ No newline at end of file diff --git a/target/classes/META-INF/maven/com.interviewPractice2026/interviewPractice2026/pom.properties b/target/classes/META-INF/maven/com.interviewPractice2026/interviewPractice2026/pom.properties index ca7da1e..42fc131 100644 --- a/target/classes/META-INF/maven/com.interviewPractice2026/interviewPractice2026/pom.properties +++ b/target/classes/META-INF/maven/com.interviewPractice2026/interviewPractice2026/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven Integration for Eclipse -#Sat Feb 28 11:30:55 IST 2026 +#Sun Mar 01 00:25:16 IST 2026 artifactId=interviewPractice2026 groupId=com.interviewPractice2026 m2e.projectLocation=D\:\\My_Project\\Testing_Project\\interviewPractice2026 diff --git a/target/test-classes/March/DuplicateWordFinder.class b/target/test-classes/March/DuplicateWordFinder.class new file mode 100644 index 0000000..b7444da Binary files /dev/null and b/target/test-classes/March/DuplicateWordFinder.class differ diff --git a/target/test-classes/March/EvenLetterPrintFromString.class b/target/test-classes/March/EvenLetterPrintFromString.class new file mode 100644 index 0000000..495cc76 Binary files /dev/null and b/target/test-classes/March/EvenLetterPrintFromString.class differ diff --git a/target/test-classes/March/SumOfNumber.class b/target/test-classes/March/SumOfNumber.class new file mode 100644 index 0000000..84217de Binary files /dev/null and b/target/test-classes/March/SumOfNumber.class differ diff --git a/target/test-classes/codeWithLogicExplanation/FindTheDuplicateNumber.class b/target/test-classes/codeWithLogicExplanation/FindTheDuplicateNumber.class new file mode 100644 index 0000000..0d084c0 Binary files /dev/null and b/target/test-classes/codeWithLogicExplanation/FindTheDuplicateNumber.class differ diff --git a/target/test-classes/codeWithLogicExplanation/NonRepeatingCharacter.class b/target/test-classes/codeWithLogicExplanation/NonRepeatingCharacter.class new file mode 100644 index 0000000..7537052 Binary files /dev/null and b/target/test-classes/codeWithLogicExplanation/NonRepeatingCharacter.class differ diff --git a/target/test-classes/codeWithLogicExplanation/PalindromNumber.class b/target/test-classes/codeWithLogicExplanation/PalindromNumber.class new file mode 100644 index 0000000..9ed38ef Binary files /dev/null and b/target/test-classes/codeWithLogicExplanation/PalindromNumber.class differ diff --git a/target/test-classes/codeWithLogicExplanation/ReversString.class b/target/test-classes/codeWithLogicExplanation/ReversString.class new file mode 100644 index 0000000..34efe5a Binary files /dev/null and b/target/test-classes/codeWithLogicExplanation/ReversString.class differ diff --git a/target/test-classes/codeWithLogicExplanation/SumOfNumber.class b/target/test-classes/codeWithLogicExplanation/SumOfNumber.class new file mode 100644 index 0000000..766ea6d Binary files /dev/null and b/target/test-classes/codeWithLogicExplanation/SumOfNumber.class differ diff --git a/target/test-classes/codeWithLogicExplanation/UpperCaseCountInString.class b/target/test-classes/codeWithLogicExplanation/UpperCaseCountInString.class new file mode 100644 index 0000000..dc772d6 Binary files /dev/null and b/target/test-classes/codeWithLogicExplanation/UpperCaseCountInString.class differ