🔥 #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
"Day 31 of #100DaysOfDSA: Printing Array Pairs with Loops"
More Relevant Posts
-
Today’s problem: Merge Two Sorted Lists 🔗 Problem: Given two sorted linked lists, merge them into one sorted list and return it. Example: Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4] Approach I used: ✅ Create a dummy node to simplify pointer operations. ✅ Use a pointer (tail) to build the merged list by comparing the heads of both lists. ✅ Append the smaller node each time and move forward. ✅ When one list ends, attach the remaining nodes of the other. A clean iterative solution that keeps the space usage minimal (O(1) extra space). ⚡
To view or add a comment, sign in
-
-
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
-
-
#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
-
-
🚀 #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
To view or add a comment, sign in
-
-
📌 Day 38/100 – Make array elements equal to zero (LeetCode 3354) 🔹 Problem: Given an integer array nums, each element can be a number or zero. You need to find how many zeros in the array can be replaced by either +1 or -1 such that the total sum on both sides of that zero (left and right) remains balanced or differs by 1. 🔹 Approach: First, calculate the total sum s of all elements. Maintain a prefix sum l as you iterate. For each zero: If l * 2 == s, both +1 and -1 replacements are valid → add 2 to ans. If |l * 2 - s| == 1, only one replacement is valid → add 1 to ans. Return the total count ans. 🔹 Key Learning: Prefix sums simplify balance-based problems. Comparing 2 * prefixSum with total sum helps quickly check left-right equilibrium. 🔹 Complexity: Time: O(n) — single pass through array Space: O(1) — no extra storage used 🔹 Hashtags: #Day38Of100 #LeetCode3354 #100DaysOfCode #Java #DSA #ProblemSolving #PrefixSum #CodingChallenge
To view or add a comment, sign in
-
-
📅 Day 52 of #160DaysofDSA 🔹 Count Pairs with Sum Less Than Target Today’s problem was an elegant use of the Two Pointer Technique — a powerful approach for solving array problems efficiently ⚡ 🧩 Problem Statement: Given an array arr[] and an integer target, find the number of pairs whose sum is strictly less than the target. 💡 Approach (Two Pointer Technique): 1️⃣ Sort the array. 2️⃣ Use two pointers: left = 0, right = n - 1. 3️⃣ If arr[left] + arr[right] < target: ➤ All pairs between left and right will also have smaller sums. ➤ Add (right - left) to count and move left++. 4️⃣ Else, move right--. ⏱ Time Complexity: O(N log N) 💾 Space Complexity: O(1) #DSA #Java #Coding #TwoPointers #ProblemSolving #Sum #Count #Target #GFG #Day52
To view or add a comment, sign in
-
-
💡 Day 34/100 ✅ Remove Zeros in Decimal Representation Today’s challenge was about removing all the zeros from a given number’s decimal form. For example, 1020030 → 123. It might look simple, but it reinforced the importance of handling edge cases like n = 0 or n = 1000, which can lead to empty strings or parsing errors. 🧠 Key Features: Practiced both String-based and Math-based approaches. Explored the difference between using int and long for large numbers. Strengthened understanding of number-to-string conversions and parsing. ⚙️ Time Complexity: O(d) (where d = number of digits) 💾 Space Complexity: O(d) #Day33Of100 #DSA #Java #ProblemSolving #CodingJourney #100DaysOfCode #LearnEveryday #LogicBuilding
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
-
-
🚀 Day 20/100 - Problem of the day:- Maximum Frequency of an Element After Performing Operations I. 🎯 Goal: To solve the problem of finding the maximum frequency of elements after performing a limited number of operations efficiently. 💡 Core Idea: Used prefix sum + frequency counting to track occurrences and determine how operations can maximize frequency in a given integer range. The approach ensures optimized performance without sorting or extra iterations. 🔑 Key Takeaway: Smart use of prefix sums and array-based frequency helps reduce complexity while handling large datasets effectively — achieving both speed and accuracy. 🧠 Space Complexity: O(n) ⚙️ Time Complexity: O(n) #100DaysChallenge #Day20 #DSA #LeetCode #Java #CodingJourney #ProblemSolving
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