🚀 Day 15 of 100 Days LeetCode Challenge Problem: Fancy Sequence Today’s problem was a design + math optimization challenge 🔥 not your typical DSA question. 💡 Key Insight: Instead of updating all elements every time (O(n)), we delay operations using math. 👉 Maintain: A global multiplier (mul) A global increment (add) So every value is interpreted as: ➡️ actual_value = val * mul + add 🔍 Core Approach: 1️⃣ append(val) Store a transformed value: val' = (val - add) / mul (handle modulo carefully) 2️⃣ addAll(inc) Just update: add += inc 3️⃣ multAll(m) Update both: mul *= m add *= m 4️⃣ getIndex(idx) Return: val * mul + add (mod 10⁹ + 7) 👉 This avoids updating the entire array repeatedly 🚀 🔥 What I Learned Today: Lazy updates can turn O(n) → O(1) Math transformations are powerful in design problems Think in terms of global effect instead of local updates 📈 Challenge Progress: Day 15/100 ✅ Halfway to 30! LeetCode, Design Problem, Math Optimization, Lazy Updates, Modular Arithmetic, Data Structures, DSA Practice, Coding Challenge, Problem Solving #100DaysOfCode #LeetCode #DSA #CodingChallenge #DesignProblem #Math #Optimization #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
LeetCode Day 15: Fancy Sequence Math Optimization
More Relevant Posts
-
I just completed 100 problems on LeetCode — but the real value is in how my thinking evolved. When I started, I struggled with basic syntax, debugging errors, and even simple problems felt overwhelming. Instead of rushing through questions, I focused on building a strong foundation step by step. Here’s how my journey progressed: 🔹 Data Structures I worked on: • Arrays • Strings • Linked Lists • Stack • HashMap 🔹 Problem-Solving Patterns I learned : • Brute Force → understanding the problem • Two Pointer technique • Sliding Window (fixed & variable) • Hashing / Frequency Maps • Prefix Sum • Slow & Fast Pointer • Stack-based problems • Monotonic Stack • Greedy Algorithms 🔹 Key Improvements: • Reduced silly mistakes (index errors, edge cases) • Better debugging and cleaner code • Shifted from “what to do” → “why it works” 📊 Stats: • 100 problems solved • 55 Easy | 41 Medium | 4 Hard • 70%+ acceptance rate 💡 Biggest realization: DSA is not about solving more problems — it’s about recognizing patterns and applying them efficiently. 🚀 Next Goals: • Solve more Medium & Hard problems • Improve speed and consistency • Prepare for real coding interviews If you're starting your DSA journey: Don’t focus on speed. Focus on understanding. Speed comes later. #leetcode #dsa #coding #programming #softwareengineering #learning
To view or add a comment, sign in
-
-
Day 93 of #365DaysOfLeetCode Challenge Today’s focus: **Sharpening problem-solving patterns & consistency** Not every day is about solving the hardest problem — some days are about **strengthening fundamentals and recognizing patterns faster**. 💡 **What I focused on today:** * Revisiting previously solved problems * Improving solution efficiency * Understanding *why* an approach works, not just *how* * Practicing edge cases and optimization thinking 📌 **Key Takeaway:** Growth in DSA isn’t just about solving new problems — it’s about: * Building intuition * Reducing solution time * Writing cleaner and more optimized code ⚡ Small improvements daily → Big results over time **What I learned today:** Consistency compounds. The more problems I revisit and refine, the more natural patterns like sliding window, prefix sums, and math-based grouping become. #LeetCode #DSA #CodingChallenge #ProblemSolving #Consistency #TechJourney
To view or add a comment, sign in
-
-
Cracking LeetCode Medium: Maximum Distance Between a Pair of Values 🚀 I recently solved a classic Two-Pointer problem: Maximum Distance Between a Pair of Values. The Problem: Given two non-increasing arrays, find the maximum j - i such that i <= j and nums1[i] <= nums2[j]. The Strategy: Two Pointers 💡 Since both arrays are already sorted (non-increasing), a nested loop (O(n²)) would be too slow. Instead, I used the Two-Pointer technique: 1️⃣ Start both pointers i and j at 0. 2️⃣ If nums1[i] <= nums2[j], it's a valid pair! Record the distance j - i and move j forward to find an even larger gap. 3️⃣ If nums1[i] > nums2[j], the current nums1[i] is too large. Move i forward to find a smaller value. Complexity: Time: O(n + m) — much faster than the O(n * m) brute force! Space: O(1) — no extra memory used. Efficient algorithms are all about leveraging the properties of the data (like sorting). Happy coding! 💻 #LeetCode #Coding #TwoPointers #Algorithms #DataStructures #TechLearning #Programming #ProblemSolving
To view or add a comment, sign in
-
🚀 Day 10 of My LeetCode Journey Not all problems are about coding… some are about thinking smarter. Solved: Minimum Operations to Make a Uni-Value Grid ✅ At first glance, it looked like a brute-force problem—but the real trick was hidden in mathematics + optimization 👀 🔹 What I did: • Converted 2D grid → 1D array • Checked feasibility using modulo condition • Used median to minimize total operations (key insight 💡) 🔹 Why median? Because it minimizes the sum of absolute differences—making the solution optimal. 🧠 Biggest Learning: Sometimes the best solution isn’t about trying all possibilities, but about understanding the math behind the problem. 📊 Stats: ⚡ Runtime: 9 ms (Beats 92.59%) 💾 Memory: 90.13 MB From brute force thinking → optimized mindset 🚀 #LeetCode #DSA #ProblemSolving #Optimization #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 66 on LeetCode — Binary Search 🔍✅ Today’s problem focused on one of the most fundamental and powerful techniques in DSA — Binary Search. 🔹 Approach Used in My Solution The goal was to find the index of a target element in a sorted array. Key idea in the solution: • Maintain two pointers: low and high • Calculate mid = low + (high - low) / 2 to avoid overflow • Compare nums[mid] with target: – If equal → return index – If greater → search left half – If smaller → search right half • Continue until the search space is exhausted This approach efficiently reduces the search space by half in every step. ⚡ Complexity: • Time Complexity: O(log n) • Space Complexity: O(1) 💡 Key Takeaways: • Mastered the core concept of divide and conquer • Learned how to safely calculate mid to avoid overflow • Reinforced understanding of searching in sorted arrays efficiently 🔥 Binary Search is a must-know pattern for interviews and advanced problems! #LeetCode #DSA #Algorithms #DataStructures #BinarySearch #Arrays #DivideAndConquer #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
🚀 Day 41 of 100 Days LeetCode Challenge Problem: Minimum Distance Between Three Equal Elements I Day 41 is a clean hashing + index tracking + greedy observation problem 🔥 💡 Key Insight: We need three indices (i, j, k) such that: 👉 nums[i] == nums[j] == nums[k] And minimize: 👉 |i - j| + |j - k| + |k - i| 🔍 Simplification Trick: If we sort indices → i < j < k, then: 👉 Distance becomes: (j - i) + (k - j) + (k - i) = 2 * (k - i) 🔥 So we only need to: 👉 Minimize (k - i) for any 3 equal elements 🔍 Core Approach: 1️⃣ Group Indices by Value Use a hashmap: value → list of indices 2️⃣ Check Each Group If size ≥ 3: Slide window of size 3 Compute k - i 3️⃣ Track Minimum Distance Answer = 2 * (k - i) 👉 If no valid triplet → return -1 🔥 What I Learned Today: Simplifying formulas can reduce complexity drastically Hashing helps group related data efficiently Sliding window works even on index lists 📈 Challenge Progress: Day 41/100 ✅ Beyond halfway to 50! LeetCode, HashMap, Arrays, Greedy, Sliding Window, Optimization, DSA Practice, Coding Challenge, Problem Solving #100DaysOfCode #LeetCode #DSA #CodingChallenge #Hashing #Arrays #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
To view or add a comment, sign in
-
-
📌 Strengthening DSA Concepts through Problem Solving Recently, I solved LeetCode 204 – Count Primes It’s a problem that looks straightforward at first, but applying the right mathematical optimization makes it much more efficient. Problem: Given an integer n Each number from 0 → n-1 can either be prime or not We need to: 👉 Count how many prime numbers are strictly less than n 🎯 Goal: return the total count of primes Naive Approach: → Check every number individually → For each number, test divisibility But this fails because: ❌ It takes too long for large inputs ❌ Time complexity becomes O(n √n) Optimized Approach (Sieve of Eratosthenes) Instead of checking each number: 👉 Eliminate non-prime numbers in bulk 👉 Use a boolean array: false → prime true → not prime 🔑 Key Idea: Mark multiples of each number as non-prime: Start from: 2 (first prime) Mark 2×2, 2×3, 2×4... Then: Move to next unmarked number Repeat the process ⚙️ Implementation (Important Code Steps) 1️⃣ Initialize array boolean[] check = new boolean[n + 1]; check[0] = true; if (n > 0) check[1] = true; 2️⃣ Mark non-primes (core logic) for (int i = 2; i * i <= n; i++) { if (check[i] == false) { for (int j = i * i; j < n; j += i) { check[j] = true; } } } 3️⃣ Count primes int cnt = 0; for (int i = 0; i < n; i++) { if (check[i] == false) { cnt++; } } 🔄 Traversal: → Start from i = 2 → If number is unmarked → it's prime → Mark all its multiples from i*i Finally: → Count all unmarked values ⏱️ Complexity: Time complexity: O(n log log n) Space complexity: O(n) 💡 Learning: Some problems are not about checking each possibility… 👉 They are about eliminating invalid cases efficiently 👉 And recognizing classic patterns like Sieve of Eratosthenes Let’s keep learning and improving every day #LeetCode #Math #Sieve #DSA #ProblemSolving #CodingJourney #InterviewPreparation
To view or add a comment, sign in
-
Growth in DSA is not just about solving problems, but about having the patience to truly understand complex ones. Day 35/100 — Data Structures & Algorithms Journey Today I took on a challenging problem — Trapping Rain Water. Instead of rushing to solve it, I focused on learning and understanding the logic behind it step by step. This problem is a perfect example of how a single question can involve multiple approaches and deep thinking. Today’s Focus: Understanding how water is trapped between elevations Breaking the problem into left max and right max concepts Exploring different approaches (Brute Force → Prefix Arrays → Two Pointers) Visualizing the problem instead of directly coding Why this matters? Because not every problem is meant to be solved instantly — some are meant to teach deeper thinking and patience. Key Takeaways: Hard problems improve problem-solving mindset Understanding the intuition is more important than memorizing solutions Visualization plays a key role in complex problems Learning multiple approaches strengthens flexibility Today wasn’t about solving fast… It was about understanding deeply. Step by step, getting stronger #Day35 #DSA #LeetCode #ProblemSolving #SoftwareEngineering #CodingJourney #100DaysOfCode #TechLearning #DeveloperJourney #Programming #Python #InterviewPreparation #CodingSkills #ComputerScience #FutureEngineer #TechCareers #SoftwareDeveloper #LearnInPublic #Consistency
To view or add a comment, sign in
-
-
🚀 Day 76 – Object-Oriented Thinking & Sorting Logic ✨ Today’s focus was on strengthening problem-solving with two powerful concepts: 🔹 OOP Introduction – Learned what a class is and how it acts as a blueprint, and what an object is as its real-world instance. This opened up a new way of thinking about structuring code — moving from procedural steps to organized, reusable design. 🔹 Insertion Sort – Explored one of the fundamental sorting techniques. Practiced how it builds a sorted list one element at a time, reinforcing the importance of algorithmic efficiency and logical flow. 🌱 Reflection – OOP feels like learning a new language of design, while insertion sort reminded me that even simple algorithms carry deep lessons in clarity and precision. Both together highlight how coding is not just about writing instructions, but about thinking in systems and patterns. ✨ Grateful to Rudra Sravan kumar sir, mounika M mam, and the 10000 Coders team for guiding me through these foundational shifts in perspective. ⚡ Day 76 was a reminder that every new concept — whether design or algorithm — adds another tool to the developer’s toolkit, shaping us into better problem-solvers. #Day76 #OOP #ClassesAndObjects #InsertionSort #Algorithms #CodingJourney #10000Coders #LearnInPublic #100DaysOfCode
To view or add a comment, sign in
-
Growth in DSA is not just about solving problems, but about recognizing patterns faster and applying them smarter. Day 30/100 — Data Structures & Algorithms Journey Continuing from yesterday’s shift, today I focused on strengthening my understanding of patterns by observing how similar problems can be solved using the same approach with slight variations. Instead of jumping directly into coding, I’m training myself to first identify the pattern behind the problem. Today’s Focus: Deep dive into Two Pointer and Sliding Window patterns Understanding when to expand vs shrink a window Identifying repeating structures across different problems Improving decision-making before implementation Why this matters? Because the ability to recognize patterns quickly is what separates a beginner from an efficient problem solver. Key Takeaways: DSA is about recognizing patterns under pressure The first step is identifying the approach, not writing code Small optimizations can make a big difference Thinking before coding improves accuracy This phase is helping me shift from solving problems randomly to solving them strategically. Excited to keep building stronger intuition and mastering patterns 🚀 #Day30 #DSA #LeetCode #ProblemSolving #SoftwareEngineering #CodingJourney #100DaysOfCode #TechLearning #DeveloperJourney #Programming #Python #InterviewPreparation #CodingSkills #ComputerScience #FutureEngineer #TechCareers #SoftwareDeveloper #LearnInPublic #Consistency
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