🚀 Day 94 of #100DaysOfCode Today I solved the "Funny String" problem on HackerRank using C 💻 🔍 Problem Insight: A string is called Funny if the absolute differences between adjacent characters are the same when compared with its reverse. 👉 Instead of actually reversing the string, I optimized the solution by comparing characters from both ends — saving space and improving efficiency. 💡 Key Learning: Efficient string traversal techniques Avoiding unnecessary space usage Writing optimized logic with O(n) time complexity 🧠 Logic in Short: Compare: |s[i] - s[i-1]| with |s[n-i] - s[n-i-1]| If all match → ✅ Funny Else → ❌ Not Funny ⚡ Example: Input: acxz → Output: Funny Input: bcxz → Output: Not Funny Consistency in small optimizations builds strong problem-solving skills over time. #Day94 #100DaysOfCode #CodingJourney #HackerRank #CProgramming #ProblemSolving #DeveloperLife #LearnToCode #CodeDaily
Solved Funny String Problem on HackerRank with C Optimizations
More Relevant Posts
-
Ever look at a LeetCode problem and think, "Oh, this is just simple math," only to see a constraint of $10^{15}$ staring back at you? That was my experience with the "Count Good Numbers" problem today. The core logic was actually pretty straightforward: even indices get even digits (5 options), and odd indices get prime digits (4 options). But trying to calculate 5^even * 4^odd for massive numbers? Immediate Time Limit Exceeded (TLE). I had to scrap the standard approach and write a custom pow() function using Binary Exponentiation. It’s wild how applying modulo 10^9 + 7 at every single multiplication step within the recursive call is the exact difference between a failing solution and a clean O(log n) pass without integer overflow. Definitely a great reminder that knowing the brute-force math is only half the battle—optimizing it is where the real engineering happens. Back to the grind! #LeetCode #DSA #CPP #CompetitiveProgramming #SoftwareEngineering #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 54 | LeetCode Learning Journal Today I solved Range Sum Query Immutable using C++. This problem was a great introduction to optimizing repeated queries using preprocessing! 🔑 Key Points: • Used Prefix Sum Array to store cumulative sums • Precomputed values to avoid recalculating sums every time • Answered each query in O(1) time • Focused on reducing time complexity from brute force O(n) to optimal 🌱 What I Learned: • How preprocessing can drastically improve performance • Concept of prefix sums and their real-world use • Trade-off between space and time complexity • Writing cleaner and efficient query-based logic #LeetCode #100DaysOfCode #DSA #CodingJourney #CPlusPlus #Algorithms #Day54 🚀
To view or add a comment, sign in
-
-
🔥 Day 76 of #100DaysOfCode Solved Climbing Stairs (LeetCode 70) today — a classic Dynamic Programming problem 🚀 At first, it looks simple… but the real learning is in identifying the pattern behind it. 💡 Key Insight: Each step depends on the previous two steps. That’s when it clicked — this is basically a Fibonacci pattern in disguise. Instead of using recursion (which is slow), I used an optimized iterative approach to achieve: ⚡ O(n) time complexity ⚡ O(1) space complexity 📈 Result: ✅ 100% runtime ✅ 90%+ memory efficiency This problem taught me: 👉 Always look for patterns before jumping into coding 👉 Optimization matters as much as correctness Small problems → Big concepts #Day76 #LeetCode #DynamicProgramming #CodingJourney #ProblemSolving #LearnInPublic
To view or add a comment, sign in
-
-
Day 6 🚀 Solved: Maximum Depth of Binary Tree (LeetCode 104) This is a classic recursion problem on trees. 💡 Key idea: The depth of a tree is 1 + the maximum depth of its left and right subtrees. 🔹 Approach: If the node is null → depth is 0 Recursively calculate depth of left and right Take the maximum and add 1 ⏱️ Time Complexity: O(n) 🔗 GitHub: https://lnkd.in/gz5mBpDx #DSA #LeetCode #Coding
To view or add a comment, sign in
-
One step closer🔥 LeetCode Progress 49/50 — Decode Ways I worked on a fundamental problem focused on dynamic programming and string decoding 🧩 💡 The challenge was to find the number of ways to decode a given digit string into letters (A–Z mapping). 🧠 Approach: Used dynamic programming to track valid decoding ways at each index. Handled edge cases like leading zeros and invalid two-digit combinations carefully. ⏱ Time Complexity: O(n) 💡 What I learned: This problem improved my understanding of DP state building and how to break a problem into smaller subproblems with valid transitions. 📈 Strengthening dynamic programming fundamentals and logical thinking for complex string problems. #LeetCode #DSA #DynamicProgramming #Strings #ProblemSolving #Cpp #CodingJourney #Consistency 🚀
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
-
-
🚀 Coding Challenge: Day 11 Solved Sqrt(x) on LeetCode. ⚡ Approach: Used Binary Search on the answer space (0 → x). Calculated mid and compared mid * mid with x: ->If equal → found exact answer ->If smaller → store mid and move right ->If larger → move left ⚡ Time Complexity: ✔ O(log x) — search space halves every step ⚡ Space Complexity: ✔ O(1) — no extra space used ⚡ Key Learning: ✔ Binary Search can be applied beyond arrays ✔ Think in terms of searching for answers, not just indices #DSA #LeetCode #BinarySearch #CPlusPlus #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 48/100 – LeetCode DSA Practice ✅ Problem Solved: 169. Majority Element Today’s problem was about finding the element that appears more than ⌊n/2⌋ times in an array. The question guarantees that such an element always exists. 💡 My Approach (Brute Force): I used two nested loops For each element, I counted how many times it appears in the array If the count is greater than n/2, I returned that element 🔍 Logic in Simple Words: Pick one element Compare it with all elements Count matches If count > n/2 → that’s the majority element 🚀 What I Learned Today: Importance of understanding the definition of majority element How brute force helps build logic step-by-step Learned about better optimization using Boyer-Moore Voting Algorithm (O(n), O(1)) Always try to improve from correct → optimal solution 📌 Problem Summary: Find the element that appears more than half the size of the array. Since it’s guaranteed to exist, we don’t need to worry about edge cases of absence. ✨ Next Step: Practice optimized approaches and improve problem-solving speed! #Day48 #100DaysOfCode #LeetCode #DSA #Java #CodingJourney #ProblemSolving #LearnToCode #TechSkills #Programmer #CodingLife #Consistency #GrowthMindset
To view or add a comment, sign in
-
-
🚀 Day 20 of My DSA Journey Another day, another step closer to mastering Greedy Algorithms 🔥 📌 Problem Solved ✅ Lemonade Change 🧠 Key Learnings 🔹 1. Greedy Choice Matters At every step, we must return change in the most optimal way: Prefer $10 + $5 over 3 × $5 👉 This ensures future transactions remain possible 🔹 2. Simplicity > Complexity Initially thought of using HashMap ❌ But realized: ➡️ Only $5 and $10 matter ➡️ Simple variables are enough ✅ 🔹 3. Pattern Recognition This problem reinforced a key idea: Not every problem needs complex data structures 📊 Performance ⚡ Runtime: 2 ms (Beats 99.76%) 💾 Memory: 72.56 MB 💡 Big Takeaway “Greedy works when making the locally optimal choice leads to a globally optimal solution.” 🔥 Slowly building intuition for when to use: Greedy Heap HashMap Consistency is starting to pay off 🚀 #DSA #Java #GreedyAlgorithm #CodingJourney #LeetCode #100DaysOfCode #Programming
To view or add a comment, sign in
-
-
When I first started with LeetCode, I wasn’t good at it—and honestly, I hated it. I’ve always been the kind of person who resists things that don’t feel natural. But once I dug deeper into systems programming, compilers, and operating systems, something clicked. Those “abstract” data structures and algorithms stopped feeling forced—they became essential. And with that shift, so did my ability to understand them. Sometimes, it’s not about forcing the skill—it’s about finding the context that makes it make sense.
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