🚀 #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
Finding Largest & Smallest in Array with Java
More Relevant Posts
-
Day 3 of #100DaysOfDSA — Search Insert Position Today’s problem: Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be inserted in order. (Time complexity: O(log n)) Approach: I used Binary Search to achieve O(log n) efficiency. Instead of linear scanning, I divided the array into halves until I found the correct position This challenge helps me strengthen my Binary Search fundamentals and build confidence in solving LeetCode-style problems. #Day3 #100DaysOfCode #DSA #LeetCode #Java #CodingJourney
To view or add a comment, sign in
-
-
🧮 Day 30 of My #100DaysOfLeetCode Challenge ✅ Problem: Find Target Indices After Sorting Array 🧩 Difficulty: Easy 📂 Category: Array / Counting ⚡ Runtime: 0 ms (Beats 100%) 💾 Memory: 44.54 MB 🔹 Approach: Instead of sorting, I used counting logic to find the number of elements smaller than the target (lessThan) and the count of target elements (count). The resulting indices are then [lessThan, lessThan + 1, ..., lessThan + count - 1]. This avoids unnecessary sorting and keeps the solution O(n). 🧠 Time Complexity: O(n) 💾 Space Complexity: O(1) ✨ Learnings: How counting-based reasoning can replace sorting for index-based problems. Focused on optimization and problem pattern recognition. 📈 Progress: Day 30 ✅ | 70 days remaining 🚀 💭 “Optimization is not about doing more — it’s about doing smarter.” #100DaysOfCode #LeetCode #Java #DSA #ProblemSolving #CodingChallenge #Consistency
To view or add a comment, sign in
-
-
🔥 #100DaysOfDSA — Day 31/100 Topic: Pairs in an Array 👯♂️ 💡 What I Did Today: Today, I learned how to print all possible pairs from an array — a great exercise to understand nested loops and how combinations work in arrays. 🧠 Logic Used: Use two loops: Outer loop picks the first element. Inner loop pairs it with every following element. Keep a counter to track the total number of pairs. 📊 Example: Input → {2, 4, 6, 8, 10} Output → (2,4) (2,6) (2,8) (2,10) (4,6) (4,8) (4,10) (6,8) (6,10) (8,10) Total pairs = 10 ⚙️ Time Complexity: O(n²) because of the nested loops. Simple yet powerful way to grasp combinations in arrays. ✨ Takeaway: Working with array pairs really strengthens how I think about nested iterations and relationships between elements. Each small step builds stronger DSA intuition 💪 #100DaysOfCode #Day31 #Java #DSA #Arrays #CodingJourney #ProblemSolving #DeveloperLife #LearnInPublic #CodeNewbie #LogicBuilding
To view or add a comment, sign in
-
-
🚀 Question 30 of my #100QuestionsOfDSA journey 💡 Problem: Reverse Linked List II Given the head of a linked list and two positions left and right, reverse the nodes between them and return the modified list. ✨ What I learned: How to reverse a specific portion of a linked list efficiently. Using a dummy node simplifies edge cases like reversing from the head. Strengthened control over pointer manipulation and linked list traversal logic. Achieved O(n) time and O(1) space complexity. 🧩 Example: Input: head = [1,2,3,4,5], left = 2, right = 4 Output: [1,4,3,2,5] #Java #LinkedList #TwoPointers #ReverseLinkedList #DataStructures #Algorithms #LeetCode #ProblemSolving #InterviewPrep #CodingJourney #100QuestionsOfDSA #DSA #CodeNewbie #TechCareer #JavaDeveloper #CleanCode
To view or add a comment, sign in
-
-
💡 #GFG160 Day 29 — Find Minimum in Rotated Sorted Array Today’s challenge was about identifying the minimum element in a sorted and rotated array — a classic binary search twist. 🧩 Problem: A sorted array is rotated at some pivot, and we need to find the smallest element efficiently. Example: arr = [5, 6, 1, 2, 3, 4] → Output: 1 ⚙️ Approach / Intuition: Since the array is sorted but rotated, one half of it remains sorted. If arr[low] <= arr[high], the array segment is sorted — so the minimum is arr[low]. Otherwise, use binary search logic to move toward the unsorted half where the minimum lies. ⏱ Time Complexity: O(log N) 🔁 Space Complexity: O(1) 🧠 Key takeaway: Binary search can be extended far beyond just “searching” — it’s all about identifying sorted patterns and narrowing down intelligently. #GeeksforGeeks #ProblemSolving #Java #CodingChallenge #DSA #BinarySearch #LearningEveryday
To view or add a comment, sign in
-
-
🚩 Problem: 283. Move Zeroes 🔥 Day 39 of #100DaysOfLeetCode 🔍 Problem Summary: Given an integer array nums, move all zeroes to the end of the array while maintaining the relative order of the non-zero elements. You must do this in-place (without using extra space). ✅ Two-Pointer Efficient Approach: Use one pointer to track the position to place non-zero elements. Iterate through the array: When a non-zero element is found, place it at the current pointer index and move the pointer forward. After processing all non-zero elements, fill the remaining positions with zeroes. 📊 Complexity: Time Complexity: O(n) Space Complexity: O(1) 🎯 Key Takeaway: This problem reinforces in-place array manipulation and the two-pointer strategy, a critical technique for optimizing time and space in real-world applications. Link:[https://lnkd.in/gwQFp3fA] #100DaysOfLeetCode #Day39 #Problem283 #MoveZeroes #TwoPointers #ArrayManipulation #DSA #Java #Algorithms #CodingChallenge #ProblemSolving #LeetCode #InterviewPrep #TechCareers #CodingCommunity #ArjunInfoSolution #SoftwareEngineering #ZeroToHero #CareerGrowth #CodeNewbie
To view or add a comment, sign in
-
-
🚩 Problem: 349. Intersection of Two Arrays 🔥 Day 42 of #100DaysOfLeetCode 🔍 Problem Summary: Given two integer arrays nums1 and nums2, return an array of unique elements that appear in both arrays. The result must not contain duplicates. The order of elements in the output does not matter. ✅ Approach: Using HashSet Store elements of nums1 in a HashSet. Loop through nums2, and if an element exists in HashSet, add to result set. Convert the set into an array. 📊 Complexity: Time Complexity: O(m + n) Space Complexity: O(m + n) 🎯 Key Takeaway: This problem reinforces the concept of using HashSet to remove duplicates and perform efficient membership checks, which is fundamental for solving array and hashing problems optimally. Link:[https://lnkd.in/gz9Y99Ak] #100DaysOfLeetCode #Day42 #Problem349 #IntersectionOfArrays #HashSet #Java #DSA #Algorithms #CodingChallenge #ProblemSolving #LeetCode #InterviewPreparation #DataStructures #TechCareers #ArjunInfoSolution #CodingCommunity #CodeNewbie #ZeroToHero #SoftwareEngineering
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 89 Linked Lists & Big Number Addition 🔹 Problem: Add Two Numbers You’re given two non-empty linked lists representing numbers. Each node stores a single digit, and the digits are stored in reverse order. 🔹 My Approach: Used a dummy node to simplify list construction. Traversed both lists simultaneously while managing the carry. Created new nodes for each digit of the sum using modular arithmetic. Continued until both lists and carry were fully processed. Time Complexity: O(max(N, M)) Space Complexity: O(max(N, M)) Even in linked lists, clean logic + careful pointer handling can simplify complex problems. This challenge reinforced how breaking big tasks into smaller, consistent steps leads to efficient solutions. #takeUforward #100DaysOfCode #LinkedList #Java #ProblemSolving #LeetCode #DSA #CodingJourney #CodeNewbie #ChitkaraUniversity
To view or add a comment, sign in
-
-
🚀 #DSAinJava #Day82 #300DayChallenge Another step forward in the #TUFWinterArc by @takeUforward! ⚡ Today was all about mastering Array Manipulation & Sorting Techniques — pushing boundaries with smart merging and mathematical insights. 💪 🧠 Topics & Problems Covered: 1️⃣ Merge Overlapping Subintervals 2️⃣ Merge Two Sorted Arrays Without Extra Space 3️⃣ Find the Repeating and Missing Number 💡 Key Learnings: 🔹 Learned how to efficiently merge overlapping intervals using sorting and linear traversal (O(n log n) ➡️ O(n)). 🔹 Explored in-place merging strategies for sorted arrays — minimizing space usage while maintaining order. 🔹 Applied mathematical and XOR-based reasoning to identify missing and repeating numbers without extra memory. 🔹 Reinforced the importance of clean implementation and careful edge-case handling in array transformations. ⚡ Mindset Upgrade: Each challenge reminded me that — ✅ Simplicity and optimization often go hand-in-hand ✅ Space-efficient logic is just as important as time optimization ✅ Patience + Precision = Progress 📂 All Solutions (Code + Notes): 👉 https://lnkd.in/deeXep9Q #TUFWinterArc #TakeUForward #Java #DSA #CodingJourney #ProblemSolving #Arrays #InterviewPreparation #LeetCode #CodeEveryday #ConsistencyWins
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟑 𝐨𝐟 #𝟓𝟎𝐃𝐚𝐲𝐬𝐎𝐟𝐃𝐒𝐀 Today’s problem was an interesting 𝐚𝐫𝐫𝐚𝐲 𝐦𝐚𝐧𝐢𝐩𝐮𝐥𝐚𝐭𝐢𝐨𝐧 challenge that combined 𝐟𝐫𝐞𝐪𝐮𝐞𝐧𝐜𝐲 𝐨𝐩𝐭𝐢𝐦𝐢𝐳𝐚𝐭𝐢𝐨𝐧 and 𝐬𝐥𝐢𝐝𝐢𝐧𝐠 𝐰𝐢𝐧𝐝𝐨𝐰 𝐥𝐨𝐠𝐢𝐜. 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐋𝐢𝐧𝐤 : https://lnkd.in/eTuHbtHe 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧 𝐋𝐢𝐧𝐤 : https://lnkd.in/eZpb7TDH 𝐏𝐫𝐨𝐛𝐥𝐞𝐦: Given an array nums and two integers k and numOperations, we can perform up to numOperations changes — where each change lets us add any value from [-k, k] to an unused element. Our goal : Maximize the frequency of any element after all operations. We can achieve this by: Adding 0 to nums[1] → [1, 4, 5] Adding -1 to nums[2] → [1, 4, 4] Approach: Count frequencies of each unique number using a map. Sort the unique keys. Use a sliding window over the range [center - k, center + k] to find the total count of numbers that can be converted into center with the given range and operations. Track the maximum achievable frequency. 𝐂𝐨𝐧𝐜𝐞𝐩𝐭𝐬 𝐮𝐬𝐞𝐝: HashMap for frequency counting Sliding Window Technique Range-based element transformation Language: Java Small optimizations and mathematical reasoning make these types of problems fun to solve! #50DaysOfDSA #DSA #CodingChallenge #LeetCode #Java #ProblemSolving #DeveloperJourney #OpenSource #Day3 #LearningEveryday
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development