Day 58 of My 90-Day Coding Challenge Today was a step back toward real problem solving. Worked on a problem that required Fast Exponentiation (Binary Exponentiation) — not something you can brute force your way through. Key learning: • When constraints are large, O(n) thinking fails • You must reduce the problem using logarithmic approaches • Repeated squaring is not just an optimization — it’s the only viable way Instead of multiplying step by step, the idea is to: • Square the base • Halve the exponent • Build the answer conditionally This reduces time complexity from O(n) → O(log n). What stood out today: Recognizing when a problem is actually about math + patterns, not loops. Back to building momentum. #90DaysOfCode #DSA #Java #BinaryExponentiation #ProblemSolving #LeetCode #Optimization
90-Day Coding Challenge: Fast Exponentiation with Binary Exponentiation
More Relevant Posts
-
At first, the Rotate Image problem looked tricky. Rotating a matrix in-place isn’t something that feels obvious right away. But after thinking about it, I realized it’s not about rotation directly, it’s about transforming the matrix step by step. By first flipping it across the diagonal (transpose) and then reversing each row, the rotation happens naturally. Moments like this remind me that in coding, the right approach often matters more than the problem itself. Learning to break problems down is the real skill. RAVI KUMAR Coding Blocks Sunstone #Coding #DSA #Java #ProblemSolving #GrowthMindset #Learning
To view or add a comment, sign in
-
-
Day 55 of 100 Days of LeetCode 💻 Today I solved Longest Consecutive Sequence — and honestly, this one taught me more about coding discipline than algorithms. At first, my approach was correct: Used HashSet for O(1) lookup Applied the “start of sequence” logic But I still got TLE. The reason? A tiny mistake: if(!set.contains(num-1)); That single ; made my condition useless and turned my O(n) solution into O(n²). 💡 Lesson learned: Don’t just think your logic is right → verify what your code actually does Small syntax mistakes can completely break optimal solutions Debugging is just as important as problem-solving Finally fixed it and got Accepted ✅ Slowly improving not just in DSA, but in writing cleaner and more careful code. #100DaysOfLeetCode #DSA #Java #CodingJourney #Learning
To view or add a comment, sign in
-
-
LeetCode Challenge – Day 13 Today I solved Problem 13: Roman to Integer (Easy). Roman numerals use seven symbols Roman numerals are usually written from largest to smallest. But when a smaller numeral appears before a larger one, we subtract it instead of adding it. Approach: Store Roman numeral values in a HashMap. Traverse the string from left to right. If the current value is less than the next value → subtract it. Otherwise → add it to the result. Time Complexity: O(n) Space Complexity: O(1) Practicing problems daily helps strengthen problem-solving and coding skills. #LeetCode #Day13 #Java #CodingChallenge #ProblemSolving #Programming #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Solved LeetCode Problem #58 – Length of Last Word Today I worked on a simple yet insightful string manipulation problem that emphasizes attention to edge cases. 🔍 Problem Insight: Given a string containing words and spaces, the goal is to find the length of the last word, ignoring any trailing spaces. 💡 Approach Used: Instead of using built-in methods like split(), I implemented an optimized approach by: Traversing the string from the end Skipping trailing spaces Counting characters until the next space is encountered This approach avoids extra space usage and improves efficiency. 🧠 Key Learning: Importance of handling edge cases like trailing spaces How reverse traversal can simplify string problems Writing memory-efficient solutions 📈 Complexity: Time: O(n) Space: O(1) ✨ Problems like this help strengthen: String manipulation skills Logical thinking Writing clean and optimized code Consistency is key—one step closer to mastering DSA! 💪 #LeetCode #DSA #StringManipulation #Coding #ProblemSolving #Java #TechJourney
To view or add a comment, sign in
-
-
🚀 Day 54 – 100 Days Coding Challenge 📌 Problem: Three Sum ⚙️ Approach • First, sort the array to make it easier to apply the two-pointer technique • Iterate through the array and fix one element at a time • For each fixed element, use two pointers (left and right) to find pairs whose sum equals the negative of the fixed element • Skip duplicate elements to avoid repeating triplets • Move pointers based on the sum: – If sum == 0 → store the triplet and move both pointers – If sum < 0 → move left pointer forward – If sum > 0 → move right pointer backward 🧠 Logic Used • Sorting + Two Pointer Technique • Handling duplicates efficiently to ensure unique triplets • Reducing time complexity from brute force O(n³) to O(n²) 🔗 GitHub: https://lnkd.in/g_3x55n8 ✅ Day 54 Completed #100DaysOfCode #Java #DSA #ProblemSolving #Algorithms #DataStructures #LeetCode #CodingPractice #TwoPointers #ArrayProblems
To view or add a comment, sign in
-
-
Day 60 of My 90-Day Coding Challenge Today I worked on a classic recursion + backtracking problem — and it really tested how well I understand breaking problems into smaller decisions. At first, it feels messy: multiple partitions, multiple choices, and many possible paths. But once you start thinking in terms of: -“Try every possible cut and validate it” the structure becomes clear. Key learning: • Recursion is about exploring all paths, not rushing to the answer • Validity checks (like palindrome here) are what control the tree • Clean backtracking (add → recurse → remove) is everything One thing that really helped today: Even if you don’t know where to start, just begin drawing the recursion tree. As you expand it step by step, the logic starts revealing itself — what choices to make, when to stop, and how to backtrack. What stood out today: Clarity in recursion doesn’t come from memorizing patterns — it comes from visualizing the process. Still improving. #90DaysOfCode #DSA #Java #Recursion #Backtracking #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 8 of 30 Days Coding Challenge Today I solved a problem on LeetCode: Minimum Distance Between Three Equal Elements. 🔍 Approach: Initially implemented a brute-force solution using three nested loops (O(n³)). It worked for smaller constraints but highlighted the importance of optimizing. 💡 Key Learning: Instead of checking all possible triplets, grouping indices of identical elements and analyzing consecutive occurrences leads to a much more efficient solution. ⚡ Optimization Insight: Reduced time complexity from O(n³) → O(n) Leveraged HashMap to store indices and process only relevant combinations. 📈 Takeaway: This problem reinforced an important concept: 👉 When dealing with repeated elements, think in terms of grouping and patterns rather than brute force. Consistency is key — learning something new every day and improving step by step. #Day8 #30DaysOfCode #CodingChallenge #LeetCode #Java #DataStructures #Algorithms #ProblemSolving #CodingJourney #SoftwareDevelopment #LearnToCode #TechGrowth
To view or add a comment, sign in
-
-
🚀 Day 6 of LeetCode Problem Solving Solved today’s problem — LeetCode #1480: Running Sum of 1d Array 💻🔥 ✅ Approach: Prefix Sum (Running Sum) ⚡ Time Complexity: O(n) 📊 Space Complexity: O(n) The task was to compute the running sum of an array where each element represents the sum of all previous elements including itself. 👉 Example: Input: [1,2,3,4] Output: [1,3,6,10] 💡 Key Idea: Keep adding elements as you traverse the array and store the cumulative sum. 👉 Core Logic: Initialize sum = 0 Traverse array Add current element → sum += nums[i] Store in result array 💡 Key Learning: Simple problems help build strong fundamentals — mastering basics like prefix sum is very important for advanced problems. Grateful to my mentor Pulkit Aggarwal — your guidance is helping me strengthen my fundamentals every day 🙌 Consistency is the key — small steps lead to big results 🚀 #Day6 #LeetCode #DSA #Java #CodingJourney #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 42 of My LeetCode Journey Today’s problem: Regular Expression Matching This wasn’t just another coding problem — it forced me to think in terms of state transitions and decision trees, not brute force. 🔍 Key Learning: - Pure recursion is not enough → leads to exponential time - Introduced Dynamic Programming (Top-Down with Memoization) - Learned how to break the problem into: - Matching current characters - Handling "*" (zero or more occurrences) 🧠 Core Insight: Instead of trying all possibilities blindly, cache results of subproblems → avoids recomputation. ⚡ Result: - Runtime: 1 ms (Beats 99.99%) - Efficient DP solution with optimal pruning 💡 Takeaway: Hard problems aren’t about syntax — they’re about modeling the problem correctly. #Day42 #LeetCode #DataStructures #DynamicProgramming #Java #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 55 – 100 Days Coding Challenge 📌 Problem: Convert Number to English Words ⚙️ Approach • Break the number into chunks of 3 digits (hundreds) using modulo and division • Process each chunk separately and map it with its corresponding scale (Thousand, Million, Billion) • Use helper arrays for: – Numbers below 20 – Tens (20, 30, …, 90) – Scale values (Thousand, Million, etc.) • For each chunk: – Convert hundreds place – Handle tens and units • Concatenate all parts in the correct order to form the final string 🧠 Logic Used • Mathematical decomposition (splitting number into base-1000 chunks) • String construction using mapping arrays • Handling edge cases like zero and trailing spaces • Modular and reusable helper function for clean conversion 🔗 GitHub: https://lnkd.in/g_3x55n8 ✅ Day 55 Completed #100DaysOfCode #Java #DSA #ProblemSolving #Algorithms #DataStructures #LeetCode #CodingPractice #Strings #MathLogic
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