Day 55 of #100DaysOfCode 🚀 Today I worked on a classic yet powerful problem: Sort Characters by Frequency. 💡 Key learning: Instead of sorting characters directly (which costs O(n log n)), we can use Bucket Sort to group characters by their frequency and build the result efficiently. 🔹 Count character frequencies using a HashMap 🔹 Use frequency as bucket index 🔹 Build the string from highest to lowest frequency ✅ Result: Optimal O(n) time complexity This problem reinforced an important lesson for me: Choosing the right data structure can completely change the efficiency of a solution. Slowly but steadily improving problem-solving clarity and optimization thinking. 💪 On to the next challenge tomorrow 🔥 #100DaysOfCode #Day55 #DSA #ProblemSolving #Java #CodingJourney #LearningEveryday #dsawithkunal
Optimizing Character Sorting with Bucket Sort
More Relevant Posts
-
Day 13/100 | #100DaysOfDSA Today’s problem: 4Sum Basically an extension of 3Sum — but with an extra layer of complexity. Approach: • Sort the array • Fix two numbers • Use two pointers for the remaining pair • Carefully skip duplicates Time complexity: O(n³) Biggest challenge? Handling duplicates cleanly without missing valid combinations. This one really tested patience and edge-case thinking. Stacking patterns day by day. 🚀 #100DaysOfCode #LeetCode #DSA #Algorithms #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity #SoftwareDeveloper #ComputerScience #CodingLife #Consistency #Programmers #TechGrowth
To view or add a comment, sign in
-
-
🚀 Day 74 of #100DaysOfCode Today I solved Search in Rotated Sorted Array from LeetCode using a modified Binary Search approach. 🧠 Problem Insight: Even though the array is rotated, one half is always sorted. By identifying the sorted half, we can decide where to move — left or right. ⚡ Key Learning: Instead of thinking “array is rotated ”, Think → “One side is still sorted ” 💻 Approach: Use Binary Search Check which half is sorted Verify if target lies in that half Reduce search space accordingly ⏱ Complexity: Time: O(log n) Space: O(1) #Day74 #100DaysOfCode #DSA #BinarySearch #Java #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 52/100: Reverse Simulation with Deques Today’s challenge: LeetCode 950 - Reveal Cards In Increasing Order. 🃏 The trick to this problem isn't moving forward; it's thinking backward. To find the original deck order, I reversed the "reveal and move to bottom" process: Sort the deck to know the target reveal order. Reverse the simulation using a Deque (Double-Ended Queue). Shift the last element to the front and add the next sorted card. Key Learning: When a process seems complex to simulate forward, try starting from the result and working back to the beginning! #100DaysOfCode #DSA #LeetCode #Java #ProblemSolving #CodingChallenge
To view or add a comment, sign in
-
-
🚀 Continuing My #100DaysChallenge Today, I solved the LeetCode problem: “Merge Sorted Array” ✅ This problem helped me practice: • Working with two arrays simultaneously • Understanding sorted order logic • Carefully handling indexes and boundaries It was a good exercise in thinking step-by-step and ensuring the final array remains sorted. Problems like this strengthen the foundation of array manipulation and logical reasoning. With each question, I’m becoming more comfortable with Java and improving my DSA fundamentals 💪 📌 Tip for beginners: When working with multiple pointers or indexes, move carefully and track each step — small mistakes can change the entire output. #100DaysChallenge #LeetCode #Java #CodingJourney #DSA #ProblemSolving #Consistency #KeepLearning
To view or add a comment, sign in
-
-
🚀 Day 74 of #100DaysOfCode Today’s challenge was a clean and efficient array problem — LeetCode: Merge Sorted Array ✅ 📌 Problem Summary You’re given two sorted arrays, where the first array has extra space at the end. The task is to merge the second array into the first in-place, keeping everything sorted. 🧠 My Approach Instead of shifting elements forward (which is costly), I used a reverse two-pointer technique: Start comparing elements from the end of both arrays Place the larger element at the last available position Move pointers accordingly until all elements are merged This avoids extra space and keeps the solution optimal. ⚙️ Complexity ⏱ Time: O(m + n) 💾 Space: O(1) (in-place merge) 🔥 Key Learning Working from the back can simplify in-place array problems Two-pointer strategies are incredibly powerful for sorted data Another day, another solid problem solved 💪 Onward to Day 75 🚀 #100DaysOfCode #LeetCode #Java #DSA #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 18/100 | #100DaysOfDSA Today’s problem: Longest Common Prefix Many strings. One shared start. Approach: • Take first string as prefix • Compare with others • Shrink prefix until it matches • If it becomes empty → no common prefix Time complexity: O(n × m) Big takeaway: Sometimes the solution isn’t adding more — it’s trimming smartly. Less guesswork. More refinement. 💡✨ #100DaysOfCode #LeetCode #DSA #Algorithms #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity #SoftwareEngineer #ComputerScience #Consistency #Programmers #TechGrowth
To view or add a comment, sign in
-
-
🚀 Day 19 of My LeetCode Challenge Today’s problem: Find All Duplicates in an Array (LeetCode 442) 🔍 Problem Summary: Given an array of integers where each value appears once or twice and lies between 1 and n, return all elements that appear twice. 🧠 Key Insight: Since numbers are in the range 1 to n, we can use the array itself to track visited elements by marking indices negative. ⚙ Approach (O(n) time | O(1) space): ✔ Traverse the array ✔ Use value → index mapping ✔ If index already negative → duplicate found ⏱ Complexity: ✅ Time: O(n) ✅ Space: O(1) 📌 What I Learned Today: Using index mapping for in-place marking How constraints help optimize space Recognizing patterns for array-based hashing #Day19 #LeetCode #Java #DSA #CodingChallenge #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 64/100 of my DSA Journey (DP / Recursion) ✅ Problem understood today: LeetCode 799 – Champagne Tower 🧠 What I learned: First approached the problem using recursion, understanding how liquid flows from one glass to the next Realized that repeated recursive calculations make the solution inefficient Then learned memoization to store previously computed states and avoid recomputation This helped me clearly see how recursion + memoization = dynamic programming 📌 Key takeaway: Memoization turns an exponential recursive solution into an efficient one. 📈 Day 64 done. Strengthening recursion and DP intuition. #LeetCode #DSA #DynamicProgramming #Memoization #Recursion #Java #ProblemSolving #Consistency #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
-
Day 67 of #100DaysOfCode Today I solved the classic Permutations problem using Backtracking (Swap Method). At first glance, it feels like we just need to “rearrange” numbers — but the real learning is understanding how recursion explores every possible arrangement systematically. 🔁 The key idea: Fix one position → try every element → recurse for the next position → backtrack. This pattern (choose → explore → undo) is the backbone of many advanced problems like: Subsets Combinations N-Queens Sudoku Solver 📌 Time Complexity: O(n!) 📌 Space Complexity: O(n) (excluding result storage) The biggest takeaway? Backtracking is not about memorizing code — it’s about mastering the decision tree in your mind. One more step forward. 🚀 #100DaysOfCode #DSA #Backtracking #Java #ProblemSolving #dsawithkunal
To view or add a comment, sign in
-
-
🚀 LeetCode Weekly Progress Update This week I focused on strengthening my understanding of: • Binary Trees (Same Tree, Inorder Traversal) • Linked List manipulation • Backtracking (Combination Sum I & II) • String problems (Multiply Strings) • Array operations (Merge Sorted Array) 📊 Current Stats: Total Problems Solved: 49 Easy: 19 Medium: 24 Hard: 6 Acceptance Rate: 58.6% Key Learning: Backtracking problems improved my recursive thinking. Tree traversal strengthened my understanding of DFS patterns. Consistency is the real game-changer in DSA preparation. Next Goal: → Improve speed → Start more Hard problems → Revise recursion patterns #LeetCode #DSA #Java #SoftwareDevelopment #Consistency
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