Here are the three titles, each 50 characters or fewer, matching the original post's sentiment and including the most important named entity: 1. Java: Second Smallest Element in Array 2. Java: First Non-Repeating Character in String 3. Java: Check Hashad Number

🔹 Problem 1: Second Smallest Element in an Array 📌 Input: Integer n (size of array), Array of n elements 📌 Output: Second smallest element in the array 🧠 Algorithm Steps: 1. Read the array elements. 2. Assume first element as first_min and second element as second_min. 3. If first_min is greater than second_min, swap them. 4. Traverse the array from index 2. 5. If current element < first_min → second_min = first_min and first_min = current element. 6. Else if current element > first_min and < second_min → update second_min. 7. If both minimum values are equal, print "No second smallest element", otherwise print second_min. 💡 Example: Input: [5, 2, 8, 1, 3] Output: 2 🔹 Problem 2: First Non-Repeating Character in a String 📌 Input: String s 📌 Output: First character that appears only once 🧠 Algorithm Steps: 1. Read the string. 2. Traverse each character. 3. For each character, count its frequency using another loop. 4. If count == 1, print that character and stop. 5. If no such character found, print -1. 💡 Example: Input: "swiss" Output: w 🔹 Problem 3: Hashad Number 📌 Input: Integer n 📌 Output: Check whether the number is Hashad or not 🧠 Algorithm Steps: 1. Store original number. 2. Find sum of digits using loop. 3. Check if original number % sum == 0. 4. If true, print "Hashad Number". 5. Otherwise, print "Not Hashad Number". 💡 Example: Input: 18 Output: Hashad Number Consistent practice of these problems is helping me improve my logical thinking, loop handling, and core Java fundamentals. 🚀 #Java #CodingPractice #ProblemSolving #CoreJava #LearningJourney

  • text

To view or add a comment, sign in

Explore content categories