🗓 Day 14 / 100 – #100DaysOfLeetCode 📌 Problem 1437: Check If All 1’s Are at Least K Places Away The goal was to determine whether every pair of consecutive 1s in the array is separated by at least k zeros. 🧠 My Approach: Traversed the array while tracking the index of the previous 1. On encountering a new 1, checked the distance from the last one. If the gap was smaller than k, the condition failed instantly. This single-pass logic keeps the solution efficient and clean. 💡 Key Learning: This problem reinforced the importance of index tracking and using simple arithmetic comparisons to validate structural constraints. It’s a great reminder that not all problems require heavy algorithms — sometimes, clarity and careful traversal are enough for an optimal solution. Small steps forward build strong reasoning over time 🚀 #100DaysOfLeetCode #LeetCodeChallenge #Python #ProblemSolving #LogicBuilding #Arrays #Algorithms #DataStructures #DSA #CompetitiveProgramming #CodingJourney #SoftwareEngineering #LearningInPublic #DeveloperJourney #TechStudent #CareerGrowth #CodeEveryday #CodingCommunity #KeepLearning #Programming #TechCareer
Solved LeetCode Problem 1437 with Simple Logic and Tracking
More Relevant Posts
-
🗓 Day 37 / 100 – #100DaysOfLeetCode 📌 Problem 3577: Count Valid Permutations Today’s problem focused on validating and counting permutations under specific structural constraints. It was a good exercise in understanding how ordering conditions restrict the total number of valid outcomes. 🧠 My Approach: Identified the minimum value in the array. A valid permutation requires that the first element must be the minimum, and that this minimum appears exactly once. If the first element isn’t the minimum → return 0 If the minimum appears more than once → return 0 For the remaining elements, the number of valid permutations is simply: (n−1)! 💡 Key Learning: This problem reinforced two important ideas: ✔ Before counting permutations, ensure all validity constraints hold. ✔ Many permutation problems simplify to factorials once structural requirements are enforced. A clean and elegant reminder that sometimes, the hardest part is identifying the constraints—not the counting. Another day, another pattern strengthened 🚀 #100DaysOfLeetCode #LeetCodeChallenge #Python #ProblemSolving #Combinatorics #Permutations #MathInCoding #Algorithms #DSA #CompetitiveProgramming #SoftwareEngineering #CodingJourney #DeveloperJourney #LearningInPublic #TechStudent #CareerGrowth #LogicBuilding #Programming #KeepLearning
To view or add a comment, sign in
-
-
🗓 Day 41 / 100 – #100DaysOfLeetCode 📌 Problem 2110: Number of Smooth Descent Periods of a Stock Today’s problem focused on identifying and counting smooth descent periods in a stock’s price history. A smooth descent period is a contiguous segment where each day’s price decreases by exactly 1 compared to the previous day. Even a single day counts as a valid period. 🧠 My Approach: Observed that the array can be broken into maximal descending segments where prices[i] = prices[i-1] - 1. Traversed the array while maintaining the current length of a smooth descent sequence. Whenever the smooth descent condition breaks, reset the length to 1. For each position, added the current length to the answer. This works because a descent segment of length k contributes: 1+2+3+⋯+k smooth descent periods in total. 💡 Key Learning: This problem reinforced a powerful counting technique: ✔ Break the array into valid segments ✔ Count subarrays using incremental accumulation ✔ Avoid nested loops by leveraging mathematical patterns It’s a great example of turning what looks like a subarray-counting problem into a simple single-pass solution. Another solid daily problem completed 🚀 #100DaysOfLeetCode #LeetCodeChallenge #Python #ProblemSolving #SlidingWindow #TwoPointers #Arrays #Algorithms #DSA #CompetitiveProgramming #SoftwareEngineering #CodingJourney #DeveloperJourney #LearningInPublic #TechStudent #CareerGrowth #Programming #KeepLearning
To view or add a comment, sign in
-
-
🚀 TODAY I LEARNED : RETURN STATEMENTS & RETURN TYPES A return statement is used to send a value back from a function. It decides what the function outputs when it is called. ✅ Why is return important? Gives the final output of a function Allows us to store and reuse results Helps in calculations, data processing, and logic building 🔍 Return vs Print print() → displays the value (for the user) return → sends the value back (for the program) 👉 A real program should use return, not print. 📌 Types of Return Values: Returning a single value Returning multiple values (Python supports this!) Returning expressions Returning booleans Returning None (default when no return) 🎯 Simple Example: A function can return two values at once: def calc(a, b): return a+b, a*b 💡 Key Takeaway A function becomes powerful only when it returns something that your program can use later. #greatcoder #Python #PythonBasics #Programming #CodingJourney #LearnPython #Functions #LearningInPublic #TechLearning #SoftwareDevelopment #CareerGrowth #LinkedInTech GREATCODER TRAININGS LLP
To view or add a comment, sign in
-
🗓 Day 47 / 100 – #100DaysOfLeetCode 📌 Problem 3783: Mirror Distance of an Integer Today’s problem was a straightforward yet satisfying one that focused on digit manipulation and basic number operations. The task was to compute the mirror distance of an integer, defined as the absolute difference between the number and its digit-reversed form. 🧠 My Approach: Observed that if the number has only a single digit, reversing it doesn’t change anything, so the mirror distance is 0. For multi-digit numbers: Converted the number to a string. Reversed the string and converted it back to an integer (automatically handling leading zeros). Calculated the absolute difference between the original number and its reverse. This results in a clean and efficient solution with minimal logic. 💡 Key Learning: This problem reinforced that: ✔ String conversion is often the simplest way to reverse digits ✔ Edge cases (like single-digit numbers or leading zeros) matter ✔ Not every problem needs complex logic — clarity is key A quick win, but an important reminder to always handle edge cases carefully 🚀 #100DaysOfLeetCode #LeetCodeChallenge #Python #ProblemSolving #StringManipulation #MathInCoding #Algorithms #DSA #CompetitiveProgramming #SoftwareEngineering #CodingJourney #DeveloperJourney #LearningInPublic #TechStudent #CareerGrowth #Programming #KeepLearning
To view or add a comment, sign in
-
-
🧠 𝗡𝗲𝘄 𝘁𝗵𝗶𝗻𝗴 𝗲𝘃𝗲𝗿𝘆 𝗱𝗮𝘆 𝘄𝗵𝗶𝗹𝗲 𝗹𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗣𝘆𝘁𝗵𝗼𝗻 Today’s practice was about something we often overlook: 👉𝗛𝗖𝗙 (𝗚𝗖𝗗) & 𝗟𝗖𝗠 It looks like basic math. But implementing it in code makes you 𝘁𝗵𝗶𝗻𝗸 𝗱𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝘁𝗹𝘆. 🔍 𝗪𝗵𝗮𝘁 𝗜 𝗽𝗿𝗮𝗰𝘁𝗶𝗰𝗲𝗱 𝘁𝗼𝗱𝗮𝘆: • Finding HCF using conditions and loops • Understanding why checking up to the minimum number works • Using HCF to calculate LCM logically • Connecting math formulas with real code 💡 𝗪𝗵𝗮𝘁 𝘁𝗵𝗶𝘀 𝗿𝗲𝗺𝗶𝗻𝗱𝗲𝗱 𝗺𝗲: • Simple problems build strong foundations • Logic matters more than shortcuts • Revisiting basics improves problem-solving confidence No big project today. Just one small concept — understood a little better. Learning doesn’t have to be fast. It just has to be 𝙘𝙤𝙣𝙨𝙞𝙨𝙩𝙚𝙣𝙩. New thing every day. One step at a time 🚀 What basic concept are you practicing right now? #Python #LearningByDoing #ProblemSolving #CodingBasics #DSA #DeveloperJourney #Consistency #LearningToCode #TechCareers #LinkedInGrowth
To view or add a comment, sign in
-
-
🗓 Day 58 / 100 – #100DaysOfLeetCode 📌 Problem 66: Plus One Today’s problem was a simple but important exercise in array manipulation and edge-case handling. Given an integer represented as an array of digits, the task was to add one to the number and return the resulting digits. 🧠 My Approach: Started from the last digit and simulated the addition of 1. If the digit was less than 9, incremented it and finished. If the digit was 9, set it to 0 and carried over to the next digit. Continued this process until the carry was resolved. Handled the special case where all digits were 9 (e.g., [9,9,9]) by adding a leading 1. This approach closely mirrors how addition works in real life. 💡 Key Learning: This problem reinforced: ✔ how to simulate arithmetic operations using arrays ✔ careful handling of carry propagation ✔ the importance of edge cases, even in easy problems A good reminder that mastering fundamentals is key to solving harder problems efficiently 🚀 #100DaysOfLeetCode #LeetCodeChallenge #Python #ProblemSolving #Arrays #Simulation #Algorithms #DSA #CompetitiveProgramming #SoftwareEngineering #CodingJourney #DeveloperJourney #LearningInPublic #TechStudent #CareerGrowth #Programming #KeepLearning
To view or add a comment, sign in
-
-
🗓 Day 36 / 100 – #100DaysOfLeetCode 📌 Problem 3583: Count Special Triplets Today’s problem involved identifying special triplets (i, j, k) such that: Updated the counters as I moved the pointer from left to right. This approach is O(n) and handles large constraints smoothly. 🧠 My Approach: A direct triple-nested loop would be far too slow for large inputs. Instead, I used two frequency counters: le → counts occurrences to the left of index j ri → counts occurrences to the right of index j For each element nums[j], I checked whether 2 × nums[j] exists on both sides: le[2 * nums[j]] counts possible i ri[2 * nums[j]] counts possible k The number of valid triplets contributed by this middle element is: 💡 Key Learning: This problem reinforced the power of: ✔ Prefix and suffix frequency tracking ✔ Avoiding brute force by reframing the relationship between indices ✔ Converting a relational condition into a multiplicative count The beauty of this challenge lies in translating a seemingly complex index-based condition into a clean counting formula. Another great day of sharpening pattern recognition and counting strategies 🚀 #100DaysOfLeetCode #LeetCodeChallenge #Python #ProblemSolving #FrequencyCounting #HashMaps #PrefixSuffix #Algorithms #DSA #CompetitiveProgramming #SoftwareEngineering #CodingJourney #LearningInPublic #DeveloperJourney #TechStudent #CareerGrowth #LogicBuilding #Programming #KeepLearning
To view or add a comment, sign in
-
-
🗓 Day 40 / 100 – #100DaysOfLeetCode 📌 Problem 3775: Reverse Words With Same Vowel Count Today’s problem was a nice mix of string manipulation and character counting. The task was to analyze a sentence word by word and selectively reverse words based on a vowel-count condition. 🧠 My Approach: Split the input string into individual words using spaces. Counted the number of vowels (a, e, i, o, u) in the first word — this becomes the reference count. For each subsequent word: Counted its vowels. If the count matched the first word’s vowel count, reversed the word. Otherwise, left it unchanged. Joined all words back together to form the final string. 💡 Key Learning: This problem reinforced: ✔ careful string parsing ✔ clean set-based vowel checking ✔ conditional transformations based on computed properties ✔ attention to problem statements — especially “based on the first word” rules It’s a good reminder that many medium problems are about implementing logic precisely, not complexity. Another clean string-processing problem completed 🚀 #100DaysOfLeetCode #LeetCodeChallenge #Python #ProblemSolving #StringManipulation #VowelCounting #Algorithms #DSA #CompetitiveProgramming #SoftwareEngineering #CodingJourney #DeveloperJourney #LearningInPublic #TechStudent #CareerGrowth #Programming #KeepLearning
To view or add a comment, sign in
-
-
✨ Today I solved LeetCode 1411 — Number of Ways to Paint N×3 Grid and learned something really powerful: 👉 Sometimes the key is not solving cell-by-cell… 💡 Instead, think row-by-row and identify repeating patterns. In this problem, every row of the grid can only exist in two valid states: 🔹 All 3 colors different 🔹 Exactly 2 colors used Once you notice this, the solution becomes a simple pattern-based DP — no complex recursion, no overthinking. 🚀 Key takeaway for me: DSA is less about remembering formulas and more about recognizing patterns. If you're learning DSA: ✅ Focus on “why this works” — not just the code ✅ Break problems into simple states ✅ Look for relationships between steps Small progress. Daily consistency. That’s the game ❤️ #leetcode #dsa #codingjourney #python #problemsolving #learning
To view or add a comment, sign in
-
-
🚀 DSA Journey – Day 5 Today, I focused on Recursion & Backtracking, understanding how problems break down into smaller subproblems 🧠🔁 🔍 What I learned: • Recursion: A function calling itself to solve a problem • Head Recursion: Recursive call happens before processing • Tail Recursion: Processing happens before the recursive call • Backtracking: Exploring all possibilities and undoing choices when needed 📌 Key Learnings: • Always define a base case to stop recursion • Recursive problems follow stack-based execution • Backtracking is useful in combinations, permutations, paths, N-Queens • Writing recursion improves problem-solving thinking 📈 One day, one concept — building strong DSA fundamentals 💪 On to Day 6! 🔥 #DSA #Python #Hashing #LeetCode #GeeksforGeeks #CodingJourney #100DaysOfCode #ProblemSolving #DailyCoding #LearningEveryDay #SoftwareEngineering #Consistency #TechJourney #Programming
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