✅ Day 70 of #100DaysOfCode🚀 🔎 LeetCode Problem No #3354 – Count Valid Selections 🛠️ Solution - https://lnkd.in/geSxHsxD Today’s challenge was all about prefix sums, conditional counting, and state validation - testing both analytical thinking and edge-case intuition. 💡 Core Concepts Explored: Optimizing array traversal with O(n) linear scans Leveraging prefix/suffix sums for fast cumulative computations Handling decision-based iteration where each index affects multiple outcomes What made this problem interesting was identifying valid transition points dynamically without brute force - a clean example of how logical reasoning and math patterns power algorithmic efficiency. Every day of this challenge reminds me: 👉 Code is not just syntax - it’s the art of structured problem-solving. #100DaysOfCode ✅ #Day70 #LeetCode #ProblemSolving #CodingJourney #DSA #Algorithm #DataStructures #CodingChallenge #DeveloperCommunity #LearnToCode #SoftwareEngineering #CodingLife #Java #CodeNewbie #AIStudent #TechJourney #CodeEveryday #ProgrammingPractice #ProblemSolvingSkills #LeetCodeChallenge #ComputationThinking #CodeMotivation #DataScience #SoftwareDeveloper #CodeBetter #StudyWithMe #TechLearning #ProgrammersLife #BuildInPublic #StudentDeveloper #DailyCoding #SelfImprovement #MindsetMatters #CodingCommunity #LeetCodeDaily #CompetitiveProgramming #TechGrowth
Day 70 of #100DaysOfCode: Solving LeetCode Problem No #3354 with prefix sums and conditional counting
More Relevant Posts
-
Day 26 of #50DaysLeetCodeChallenge 🧩 Problem: 561. Array Partition Today’s problem was a refreshing one — an Easy-level LeetCode challenge that reinforces how sorting and pairing can optimize outcomes. It’s one of those problems that looks simple but beautifully demonstrates the power of greedy algorithms. 🧠 Thought Process: 🔹 The task is to group integers into pairs such that the sum of the smaller element in each pair is maximized. 🔹 Sorting the array ensures each pair is as balanced as possible. 🔹 Once sorted, we simply take every alternate element (starting from index 0), since that will always represent the smaller element in each optimal pair. 🔹 This method eliminates unnecessary complexity and ensures maximum total sum. ⚙️ My Approach: 🔸 Sort the array using Arrays.sort(nums). 🔸 Initialize sum = 0. 🔸 Loop through the array with a step of 2, adding nums[i] to the sum each time. 🔸 Return the final sum — the maximum possible result. 📈 Performance: ✅ Accepted ⚡ Runtime: 17 ms (Beats 13.97%) 💾 Memory: Efficient and clean implementation 💡 Reflection: Sometimes, simplicity is the key to optimization. Even without complex data structures, understanding the problem’s core logic can lead to elegant solutions. Each day’s challenge sharpens both reasoning and coding clarity. Grateful to Trainer Shishir chaurasiya and PrepInsta for guiding me through consistent, concept-driven learning in DSA 🙏 #LeetCode #50DaysLeetCodeChallenge #ProblemSolving #Java #AlgorithmDesign #CodingChallenge #PrepInsta #DeveloperJourney #LogicBuilding #DSA #CleanCode #LearningEveryday
To view or add a comment, sign in
-
-
🚀 Day 23 of #50DaysLeetCodeChallenge Problem: Binary Search (LeetCode 704) — a timeless classic that reminded me how elegance in programming often lies in simplicity. 🎯 🧠 Thought Process: When dealing with sorted data, you don’t need to search everything — just guide your logic efficiently. Binary Search embodies this idea perfectly: divide, compare, and conquer. It’s all about making smarter moves, not more moves. ⚙️ Approach: 🔹 Initialized two pointers — low and high — to define the search boundaries. 🔸 Calculated the midpoint each time and compared it with the target. 🔹 Adjusted the range intelligently, narrowing down until the target was found (or confirmed missing). 🔸 Returned the index if found, else -1. 📊 Efficiency: ✅ Time Complexity: O(log n) ✅ Space Complexity: O(1) ⏱️ Runtime: 0 ms — Beats 100% of Java submissions! ⚡ 💭 Key Takeaway: Binary Search teaches that speed isn’t always about doing more work, but about doing the right work. It’s a clear reminder that logic and precision go hand in hand when optimizing performance. 💫 Big thanks to Trainer Shishir chaurasiya and PrepInsta for constantly fueling my journey toward sharper logic and smarter problem-solving! 🚀 #LeetCode #Day23 #50DaysOfCode #ProblemSolving #Java #AlgorithmDesign #BinarySearch #CodingChallenge #PrepInsta #DSA #TechLearning #LogicBuilding #DeveloperJourney #ProgrammingLife #CodingLife
To view or add a comment, sign in
-
-
🔥 Day 150 of #1000DaysOfCode — One Hundred and Fifty Days of Consistency 💥 🔗 LeetCode Profile: leetcode.com/u/Rhythan 🔗 GitHub Day 150 Code: https://lnkd.in/gvgacGhq 🧩 Problem: 633. Sum of Square Numbers Difficulty: Medium Category: Math | Two Pointers 🧠 Concept Overview: This problem explores the idea of checking if a number can be represented as the sum of squares of two integers. It’s a classic number theory problem connected to Fermat’s theorem on sums of two squares, which states that a number can be expressed as the sum of two squares if and only if every prime factor congruent to 3 mod 4 appears an even number of times. However, here we take a computational approach using two pointers — one starting from 0 and the other from √c — to efficiently verify whether such a pair exists. ⚙️ Approach Summary: Use two pointers to navigate from both ends towards the middle. Compute the sum of their squares. Adjust the pointers depending on whether the sum is smaller or greater than the target number c. This avoids unnecessary iterations and keeps the solution optimal. 💡 Key Takeaways: Combines mathematical intuition with an algorithmic mindset. Reinforces the importance of pointer-based problem-solving patterns. Showcases how math and programming often merge beautifully in problem-solving. Demonstrates consistent mastery across different topics — Binary Search, Math, and Logic. 🚀 Reflection: 150 days of focused practice. 💪 150 days of sharpening logic, discipline, and consistency. 🧩 Every solved problem adds a new layer to your confidence and coding intuition. It’s not just about solving — it’s about building momentum and mastering the art of persistence. You’re no longer just learning — you’re evolving. 🌟 ✅ Progress: Day 150 of #1000DaysOfCode Completed 📈 Consistency Level: Legendary 🔥 Next Goal: Day 200 — Keep pushing boundaries! #1000DaysOfCode #Day150 #LeetCode #MathProblems #TwoPointers #ProblemSolving #JavaDeveloper #CodingChallenge #RhythanCodes #LearnEveryday #ProgrammingJourney #DeveloperLife #AlgorithmicThinking #CodeNewbie #BuildInPublic #CodingStreak #DailyLeetCode #ConsistencyWins #CodeEveryday #Motivation #KeepLearning #NeverStopCoding #SoftwareEngineering #MathAndLogic #ChallengeYourself #Persistence #Discipline #Rhythan1000DaysChallenge
To view or add a comment, sign in
-
-
Day 114/250 🚀 99% of beginners struggle with this simple merge logic! Today I solved the “Merge Sorted Array” problem — one of the most asked coding interview questions (LeetCode #88). The challenge: 👉 Merge two sorted arrays nums1 and nums2 into a single sorted array, without using extra space. 👉 The twist? You must do it in-place, directly inside nums1. 💭 Most people try merging from the front — and overwrite existing elements! The trick is to start from the end of both arrays and fill from the back. Here’s the logic in simple words: 1️⃣ Keep three pointers — one at the end of valid nums1, one at the end of nums2, and one at the last index of nums1. 2️⃣ Compare the elements and place the larger one at the end. 3️⃣ Move backwards until everything is merged. ✅ Time Complexity: O(m + n) ✅ Space Complexity: O(1) ✅ Language Used: C++ 🔥 Hashtags #Coding #LeetCode #Java #DSA #Programming #100DaysOfCode #SoftwareEngineering #CodeNewbie #TechCareer #InterviewPreparation #LeetCodeChallenge #ProgrammersLife #LearnToCode #DeveloperCommunity #ProblemSolving #LinkedInCoding #ViralPost Would you like me to make it sound a bit more casual and story-style (like something that goes viral among students and developers)?
To view or add a comment, sign in
-
-
Day 25 of #100DaysOfCode 🚀 Today’s focus was on sharpening fundamentals with a classic string problem — simple on the surface, yet excellent for refining logical clarity and attention to detail. 🧩 Problem — Consonants and Vowels Check (GfG) The task: Count vowels and consonants in a string and compare them. What made it interesting? Even a basic comparison can fail if you don’t handle spaces, symbols, or case variations. Filtering only valid alphabets before counting was crucial for achieving accurate results. Key Java takeaway: Clarity in input constraints and precise condition handling matter more than complexity. 💡 Key Learning String problems are not just about characters—they’re about discipline in logic: ✔ Clean input ✔ Handle edge cases ✔ Keep code simple and readable Improving these fundamentals builds the precision needed for advanced DSA topics. #100DaysOfCode #Day25 #CodingJourney #JavaDeveloper #DSA #StringProblems #GeeksforGeeks #CodingPractice #LearningEveryday #ProgrammerLife #TechJourney #ProblemSolving #CodingCommunity
To view or add a comment, sign in
-
-
🚀 LeetCode Daily Challenge – Day 41 🧩 Problem: LeetCode 3346 – Maximum Frequency of an Element After Performing Operations I 🔗 Problem Link: https://lnkd.in/gV2kWUHi 🧠 Intuition: Today’s problem pushes our understanding of frequency optimization and prefix sum logic. We’re given an array of numbers, and through at most ops operations, we can increase or decrease elements by up to k. Our goal is to determine the maximum possible frequency of any number after all allowed operations. The challenge lies in efficiently computing how many numbers can be adjusted to match a target value within the allowed range — without simulating every operation. ⚙️ Approach (Prefix Sum + Range Counting): 1️⃣ Find the maximum element mx in the array to define bounds. 2️⃣ Create a frequency array f[] to count occurrences of each number. 3️⃣ Build a prefix sum array pre[] to quickly calculate counts in any range [l, r]. 4️⃣ For every target t: Define the valid range [t - k, t + k] (numbers that can become t). Calculate total numbers within that range using prefix sums. Combine direct matches and allowed operations to maximize the frequency. 5️⃣ Track and return the highest possible frequency. 💡 Key Insight: Instead of brute-forcing every operation, leveraging prefix sums allows you to count potential matches in O(1) per target — turning a potentially quadratic approach into an efficient one. ⏱️ Time Complexity: O(n + m) — linear in range size 💾 Space Complexity: O(m) — extra arrays for frequency and prefix sums 📈 Learning from Day 41: Optimization often comes from rethinking how to count efficiently. Using prefix sums or precomputed ranges can turn heavy simulation problems into elegant linear solutions. 🌟 Motivation: Each challenge, big or small, teaches you a new way to think — and that’s how real growth happens in DSA. Stay curious, stay consistent, and keep leveling up! 💪 #️⃣ Hashtags: #Day41 #LeetCode #CodingChallenge #DSA #Java #PrefixSum #Optimization #AlgorithmDesign #ProblemSolving #KeepCoding #CodeEveryday #LearningJourney #GrowthMindset #100DaysOfCode
To view or add a comment, sign in
-
-
💻 Day 50 of My #LeetCode Challenge 🚀 Problem: LeetCode #2942 – Find Words Containing Character 🧠 Approach Used: Iterative traversal with character comparison using nested loops. 🔍 Explanation: The problem requires finding all indices of words that contain a specific character x. Here’s how I approached it: 👉 I iterated through each word in the array. 👉 For every word, I converted it to a character array to check each character individually. 👉 If any character matched x, I added that word’s index to the result list. 👉 To optimize performance, I used a break statement once the match was found to skip further checks in that word. This simple yet efficient logic ensures we minimize unnecessary comparisons while keeping the implementation easy to understand. It also demonstrates the importance of early exits (break) when dealing with nested loops. ⏱ Time Complexity: O(n * m) 🔹 n = number of words 🔹 m = average length of each word 💾 Space Complexity: O(k) 🔹 k = number of words containing the target character Each challenge strengthens logic, precision, and coding discipline — proud to reach halfway through the journey! 💪 #Day50 #LeetCode #CodingChallenge #Java #100DaysOfCode #ProblemSolving #CSE #Learning #Milestone
To view or add a comment, sign in
-
-
Leveling Up Every Day Continuing my #100DaysOfLeetCode journey! #Day 34/100 LeetCode Challenge: Problem : Next Permutation ###31 LeetCode : https://lnkd.in/gCgwuccf Today I solved one of the classic problems in array manipulation — Next Permutation. The goal is to rearrange the numbers to form the next lexicographically greater permutation of the sequence. If such a rearrangement isn’t possible (the array is in descending order), we simply return the smallest possible order (ascending). Understanding the Logic Let’s say we have an array: [1, 2, 3] The next permutation would be [1, 3, 2] If the array is [3, 2, 1], it’s already the highest permutation — so we reverse it to [1, 2, 3]. Step-by-Step Approach Find the first decreasing element when traversing from the right. → This identifies the pivot point where the next permutation change must occur. Find the element just greater than this pivot (on the right side). → Swap these two elements to slightly increase the sequence lexicographically. Reverse the part after the pivot → This ensures the remaining sequence is the smallest possible order after the swap. Key Insights Runs in O(n) time — just a few traversals of the array. Uses O(1) extra space — all operations are in-place. A perfect example of logic, observation, and attention to detail working together. Personal Note This problem tested my understanding of how permutations and lexicographical ordering actually work behind the scenes. It’s a great exercise to sharpen problem-solving and array manipulation skills in Java. #100DaysOfCode #100DaysOfLeetCode #Java #ProblemSolving #DSA #CodingJourney #LeetCode #CodingChallenge #Programming #SoftwareEngineering #DataStructures #Algorithms #TechLearning #Math #CodeEveryday #JavaProgramming #LearnToCode #DeveloperJourney #DailyCoding #Developerlife #Coderlife #LearnToCode #ConsistendLearning #LearningEveryday
To view or add a comment, sign in
-
-
How I'm Building My DSA Foundation: A Step-by-Step Roadmap A few weeks back, I sat down and made a simple plan to get good at Data Structures & Algorithms once and for all; good, here, meaning actually understand how things work under the hood, not only for cracking interviews. Here's what my roadmap looks like Step 1: Choose ONE Language & Learn the Basics ➡️ Java, C++ ,Python ,C Emphasize syntax, loops, functions, and OOP. Let's not jump between languages - depth > breadth. Step 2: Understand Time & Space Complexities Before solving problems, learn to measure efficiency. Big-O Cheat Sheet https://lnkd.in/dCjiDwTk Step 3: Deep Dive into DSA Concepts Here's my hitlist: Searching & Sorting Divide & Conquer Hashing Computer Algorithms-Greedy Algorithms Recursion & Backtracking Trees & Graphs Dynamic Programming DSA Guide- GeeksforGeeks https://lnkd.in/dCZdNv5b Step 4: Practice Religiously Platforms I use daily: LeetCode https://leetcode.com/ HackerRank https://lnkd.in/d2Y3yWcw CodeWars https://www.codewar.com/ CodeChef https://www.codechef.com/ Codeforces https://lnkd.in/d5R9PKnA Step 5: Compete & Track Growth Join coding contests they're the best reality checks. LeetCode Weekly https://lnkd.in/dnzCt72H CodeChef Contests https://lnkd.in/d7GEAUvs TopCoder https://www.topcoder.com/ ⚡My personal rule: “1 problem a day keeps imposter syndrome away.” Stay consistent. Don’t compare. Keep building. #DSA #CodingJourney #100DaysOfCode #TechLearning #ProblemSolving #SoftwareEngineering #CodeNewbie #Developer
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