🚀 Day 54 of my #100DaysOfCode Journey Today, I solved LeetCode – Sort Array By Parity II Problem Insight: Rearrange the array such that even-indexed positions have even numbers and odd-indexed positions have odd numbers. Approach: • Created a new result array of same size • Used two pointers: evenplace = 0 and oddplace = 1 • Traversed the array once • Placed even numbers at even indices and odd numbers at odd indices • Incremented pointers by 2 to maintain correct positions Time Complexity: O(n) | Space Complexity: O(n) Key Takeaway: Using two pointers for index placement makes the solution clean, efficient, and avoids unnecessary swaps. #DSA #Java #LeetCode #100DaysOfCode #CodingJourney
Sort Array By Parity II LeetCode Solution
More Relevant Posts
-
🚀 Day 27/100 Days of Code Challenge Today’s problem: Find Peak Element (Leetcode 162) 🔍 What I learned: How to find a peak element efficiently without scanning the entire array Using Binary Search to reduce time complexity from O(n) to O(log n) Understanding how the “slope” of elements helps decide the search direction 🧠 Key Idea: Instead of checking every element, compare the middle element with its neighbor: If nums[mid] < nums[mid + 1] → move right Else → move left ✅ Example: Input: [1, 2, 3, 1] Output: 2 (index of peak element 3) Consistency is key 🔑 — improving problem-solving skills one day at a time! 💪 #Day27 #100DaysOfCode #LeetCode #BinarySearch #DSA #Java #CodingJourney
To view or add a comment, sign in
-
-
Day 78 of #LeetCode 🚀 Solved: Number of Steps to Reduce a Number to Zero Today’s problem was simple but a great reminder of how important basic logic and loops are. 💡 Key Idea: If number is even → divide by 2 If odd → subtract 1 Repeat until it becomes 0 📌 Focus: Strengthening fundamentals Writing clean and efficient logic Consistency > Complexity 💯 Slowly building problem-solving mindset every day. #Day78 #CodingJourney #Java #DSA #LeetCode #Consistency #FutureDeveloper
To view or add a comment, sign in
-
-
🚀 Day 3 of #LeetCode Challenge 🔍 Problem: Length of Last Word 💡 Approach: *Started from the end of the string and counted characters until a space was found. *First, trimmed extra spaces using trim() *Traversed backward using a loop Counted characters until hitting a space 🧠 Key Concept: Reverse traversal of strings + handling trailing spaces efficiently. 🔥 #Day3 #LeetCode #Java #DSA #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 69 — LeetCode Practice 🚀 Today’s focus was on string manipulation and careful indexing. ✅ Problem solved today: 🔹 Find Common Characters 💡 Key learnings from today: • Understood how to find common characters across multiple strings • Learned the importance of character frequency counting • Practiced handling nested loops efficiently • Realized how small mistakes in indexing can affect the entire logic • Improved attention to detail while working with strings Initially, I made a mistake by using the wrong variable inside charAt(). This caused incorrect indexing, which can either lead to wrong output or even StringIndexOutOfBoundsException. After fixing it, the logic worked perfectly by correctly comparing characters and tracking their minimum frequency across all words. This problem reinforced an important lesson: Sometimes errors are not in logic — but in small details like indexing and variable usage. Accuracy matters as much as logic. Step by step, getting better 💪 On to Day 70 🚀 #Day69 #DSA #LeetCode #ProblemSolving #Java #CodingJourney #Consistency #FutureEngineer
To view or add a comment, sign in
-
-
🚀100 Days of Code Day-26 LeetCode Practice – Remove Duplicates from Sorted Array Solved a classic problem using the Two Pointer Technique 💡 📌 Problem: Given a sorted array, remove duplicates in-place and return the number of unique elements. 🔍 Key Idea: Since the array is sorted, duplicates are adjacent. Using two pointers helps efficiently overwrite duplicates without extra space. ⚡ Complexity: Time → O(n) Space → O(1) 💻 Clean and optimized approach makes this problem a great example of in-place array manipulation! #LeetCode #Java #DataStructures #CodingPractice #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 67 of #LeetCode Challenge ✅ Problem Solved: Check If Two String Arrays are Equivalent 💡 What I learned today: • Learned how to compare two string arrays without joining them • Understood how to traverse multiple strings using pointers • Improved handling of indices across arrays and strings • Realized the importance of edge cases to avoid runtime errors 🧠 Approach: • Used four pointers to track positions in both arrays and strings • Compared characters one by one • Moved to the next string when current string ends • Ensured both arrays are fully traversed at the end 📊 Key Takeaway: Efficient solutions avoid extra space — comparing character by character is better than building new strings 🔥 Consistency + small improvements every day = big progress #Day67 #LeetCode #CodingJourney #DSA #Java #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 74 — LeetCode Practice 🚀 Today’s problem: Split a String in Balanced Strings 💡 What I learned today: • Understood the concept of balanced strings (equal number of 'L' and 'R') • Learned how to use a counter approach instead of extra space • Practiced greedy logic to split the string at the right moment • Improved my ability to track conditions while iterating through strings 🧠 Key Idea: Maintain a counter → Increment for 'L' Decrement for 'R' Whenever the counter becomes 0, we found a balanced substring ✅ 🔥 Takeaway: Simple logic + careful observation = efficient solution Consistency is the real game changer 💯 #Day74 #LeetCode #DSA #Java #CodingJourney #Consistency #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 8 of #100DaysOfCode Solved: Maximum Product of Two Elements in an Array 💻 Today’s problem was all about optimizing logic and thinking smart instead of brute force. Instead of checking every pair, I focused on finding the two largest elements efficiently and used them to compute the result in a single pass 🔥 ✅ Time Complexity: O(n) ✅ Space Complexity: O(1) Small problems like these really sharpen problem-solving skills and reinforce the importance of clean, efficient code. Consistency is key — showing up every day, learning something new, and getting 1% better 💯 #DSA #Java #CodingJourney #LeetCode #ProblemSolving #Consistency #Day8#DSAwithEdSlash
To view or add a comment, sign in
-
-
Day 31/50 🚀 — Reverse Vowels of a String (LeetCode 345) Today’s problem was a great reminder that sometimes the simplest approaches are the most efficient. 🔹 Used the two-pointer technique 🔹 Focused on in-place swapping 🔹 Optimized for both time (O(n)) and space (O(1)) Key takeaway: Instead of overthinking, break the problem into smaller checks—identify vowels, move pointers smartly, and swap only when needed. Clean and efficient 💡 Happy to see this solution performing well: ⚡ Runtime: 2 ms (faster than 99%+) 📦 Space: Decent optimization #Day31 #LeetCode #DSA #Java #CodingJourney #50DaysOfCode #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 8 / 150 – LeetCode Challenge 📌 Problem: Plus One Today’s problem was simple but teaches an important concept — handling carry in arrays. 💡 Given a number represented as an array of digits, we need to add +1 and return the result. 🔑 Key Insight: - Start from the last digit - If digit < 9 → just add 1 and return - If digit == 9 → make it 0 and carry forward - If all digits are 9 → create a new array with leading ⚡ Time Complexity: O(n) ⚡ Space Complexity: O(1) (except edge case) Consistency > Motivation. 8 days done, 142 to go 💪 #LeetCode #CodingChallenge #DataStructures #Java #Consistency #100DaysOfCode #CodingThinker
To view or add a comment, sign in
-
Explore related topics
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