Finding Largest & Smallest in Array with Java

🚀 #100DaysOfDSA — Day 28/100 Topic: Find Largest & Smallest Element in an Array 💻 💡 What I Did Today: Today, I learned how to find both the largest and smallest numbers in an array using simple iteration and logic. It’s a great exercise to understand array traversal, comparisons, and the importance of initializing with extreme values (Integer.MIN_VALUE & Integer.MAX_VALUE). 🧠 Logic Used: Initialize largest as Integer.MIN_VALUE and smallest as Integer.MAX_VALUE. Traverse the array once. Update largest if the current element is greater. Update smallest if the current element is smaller. 📊 Example: Input → {1, 3, 5, 6, 4} ✅ Output → Largest Value: 6 Smallest Value: 1 ✨ Takeaway: This simple logic helps build a strong foundation for array-based problem solving — and it’s the base for many advanced algorithms like min-max difference, sorting, and range queries 💪 #100DaysOfCode #Day28 #Java #DSA #Arrays #ProblemSolving #CodingJourney #LearnInPublic #CodeNewbie #DeveloperLife

  • text

To view or add a comment, sign in

Explore content categories