Day 33 of #100DaysOfCode 🚀 Today, I learned about Counting Sort in Data Structures and Algorithms and solved a coding problem based on it. Here’s what I explored in more detail: Finding the frequency of each unique element Understanding and analyzing the time complexity of arrays Performing dry runs to better understand code execution #100DaysOfCode #DSA #Java #CountingSort #Algorithms #CodingProblem
Counting Sort Algorithm and Coding Problem Solution
More Relevant Posts
-
🚀 Day 37 of My Coding Journey Today, I solved an interesting problem on array manipulation where I learned how to efficiently build a target array using given index positions. Instead of manually handling shifts, I used a loop along with dynamic data structures to simplify insertion and maintain clean logic. This helped me better understand the importance of choosing the right data structure to reduce complexity. 💡 Key takeaway: Using the right approach can turn a complex problem into a simple one. #Day37 #CodingJourney #Java #DSA #ProblemSolving #LeetCode #LearningInPublic
To view or add a comment, sign in
-
-
60-Day LeetCode Challenge – Day 43 Solved Check If Two String Arrays are Equivalent on LeetCode. 📌 Approach: Concatenated both string arrays into two strings and compared them using .equals(). 🧠 Learning: Reinforced how string building and comparison works, especially when data is split across arrays. ⚡ Complexity: • Time Complexity: O(n + m) • Space Complexity: O(n + m) Simple logic, but a clean reminder that breaking a problem down makes it easier to solve. #LeetCode #DSA #Java #Strings #Consistency #ProblemSolving #LeetCode60
To view or add a comment, sign in
-
-
Day 91 of #365DaysOfLeetCode Challenge Today’s problem: **Arithmetic Slices (LeetCode 413)** An interesting problem that focuses on identifying patterns in subarrays. The goal is to count all contiguous subarrays of length ≥ 3 where the difference between consecutive elements remains constant. 💡 **Key Insight:** Instead of checking every subarray (which would be inefficient), we track the current streak of arithmetic sequences. * If the current 3 elements form an arithmetic sequence → extend the streak * Keep adding the count of valid slices ending at current index * Reset when the pattern breaks 📌 **Approach:** * Use two variables: * `curr` → counts current valid extensions * `total` → accumulates final answer * Traverse from index 2 onward * Compare consecutive differences ⚡ **Time Complexity:** O(n) ⚡ **Space Complexity:** O(1) **What I learned today:** Sometimes, problems that look like they need nested loops can be optimized using pattern tracking and dynamic accumulation. Consistency is key — 91 days down, 274 to go! #LeetCode #DSA #CodingChallenge #Java #ProblemSolving #100DaysOfCode #TechJourney
To view or add a comment, sign in
-
-
🚀 Day 26/100 Days of #CodeChallenge Today’s problem: Isomorphic Strings (Leetcode 205) This problem helped me understand how to map characters between two strings while maintaining consistency and order. 💡 Key Concept: Two strings are isomorphic if characters in one string can be replaced to get the other string — with: ✔️ One-to-one mapping ✔️ No two characters mapping to the same character ✔️ Order preserved 🧠 What I Learned: How to use mapping (arrays/hashmaps) efficiently Importance of bidirectional checking Handling edge cases like unequal lengths ⚡ Approach: Compare lengths first Track character mappings using arrays Ensure consistency in both directions ⏱️ Complexity Analysis: Time Complexity: O(n) → We traverse the strings once Space Complexity: O(1) → Fixed-size arrays (256 characters) ✅ Successfully solved and understood the logic! Every day is a step closer to mastering problem-solving 💪 #Day26 #100DaysOfCode #Java #DSA #LeetCode #CodingJourney #ProblemSolving #TechLearning
To view or add a comment, sign in
-
-
🚀 Day 39 of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Concatenation of Array Problem Insight: Given an integer array nums, the goal is to create a new array by concatenating the array with itself. Approach: • Created a new array of size 2 * nums.length • Used a single loop to iterate through the array • Stored elements at two positions: - result[i] = nums[i] - result[i + nums.length] = nums[i] • This avoids using extra loops and keeps the solution efficient Time Complexity: • O(n) — only one traversal required Space Complexity: • O(n) — new array is created Key Learnings: • Efficient index handling can simplify problems • Avoid unnecessary loops for better performance • Strong fundamentals make simple problems powerful Takeaway: Smart thinking beats brute force — even simple problems can be solved in an optimal and elegant way . #DSA #Java #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #Arrays
To view or add a comment, sign in
-
-
🚀 Day 3/100 – LeetCode Challenge 🔍 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 to maintain the sorted order. 💡 Key Concepts Used: • Binary Search • Time Complexity Optimization – O(log n) • Efficient searching in sorted arrays 📚 What I Learned: • How binary search reduces search time significantly compared to linear search • Handling edge cases when the target element is not present • Determining the correct insertion index while maintaining sorted order hashtag #100DaysOfCode #LeetCode #Java #DataStructures #Algorithms #BinarySearch #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 2 of #100DaysOfCode — Majority Element (LeetCode 169) Today I solved the Majority Element problem using the Boyer-Moore Voting Algorithm — a brilliant technique that finds the majority element in O(n) time and O(1) space. 💡 Key Takeaways: • Learned how cancelling non-majority elements still preserves the majority • Understood why Boyer-Moore is more optimal than sorting or HashMap • Practiced writing clean and efficient Java code Problem: Find the element that appears more than ⌊n/2⌋ times in an array. Every day, one step closer to mastering Data Structures & Algorithms and becoming a better Software Engineer. 🔥 Consistency > Perfection. #100DaysOfCode #LeetCode #Java #DSA #CodingJourney #ProblemSolving #SoftwareEngineering #LearningInPublic #TechJourney
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 54 of LeetCode Problem Solved! 🔧 🌟 560. Subarray Sum Equals K 🌟 🔗 Solution Code: https://lnkd.in/g5VwiFKd 🧠 Approach: Prefix Sum & Hash Map Store cumulative sums in a Map Check for (current_sum - k) to find matching subarrays in one pass ⚡ Key Learning: Mastering the Prefix Sum + HashMap pattern is a game-changer for transforming $O(n^2)$ subarray problems into efficient $O(n)$ solutions. ⏱️ Complexity: Time: O(n) Space: O(n) #LeetCode #Java #DSA #ProblemSolving #Consistency #100DaysOfCode #CodingJourney #PrefixSum #DataStructures
To view or add a comment, sign in
-
-
🚀 Day 82 – DSA Journey | Same Tree using Recursion Continuing my daily DSA practice, today I worked on a problem that strengthened my understanding of tree comparison and recursion. 📌 Problem Practiced: Same Tree (LeetCode 100) 🔍 Problem Idea: Given two binary trees, determine whether they are identical in both structure and node values. 💡 Key Insight: To check if two trees are the same, we need to compare nodes at every level — both their values and their left & right subtrees. Recursion makes this process clean and intuitive. 📌 Approach Used: • If both nodes are null → trees match at this point • If one is null or values differ → trees are not the same • Recursively compare left subtrees • Recursively compare right subtrees • Both sides must match for the trees to be identical 📌 Concepts Strengthened: • Tree traversal • Recursion • Structural comparison • Base case handling ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(h) (recursion stack) 🔥 Today’s takeaway: Tree problems often become simple when broken down recursively — solve smaller subtrees to solve the whole tree. On to Day 83! 🚀 #Day82 #DSAJourney #LeetCode #BinaryTree #Recursion #Java #ProblemSolving #Coding #LearningInPublic #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