🔥 Day 53 of #100DaysOfCode Solved – Number of Steps to Reduce a Number to Zero 🔍 What I did: Simulated the process by repeatedly checking whether the number is even or odd. If even, divided by 2; if odd, subtracted 1 — counting each step until the number became zero. 💡 Key Learning: Strengthened understanding of conditional logic (even vs odd) Practiced step-by-step simulation problems Learned a cleaner approach using bit manipulation (num & 1) ⚡ Result: ✅ Accepted ⚡ Efficient and clean solution 🎯 Takeaway: Breaking a problem into simple rules and simulating them step-by-step can make even tricky problems easy to solve. #Day53 #LeetCode #Java #ProblemSolving #CodingJourney #100DaysOfCode #DSA
Reducing Numbers to Zero with Conditional Logic
More Relevant Posts
-
🚀 Day #97/100 – LeetCode Challenge 𝐓𝐨𝐝𝐚𝐲’𝐬 𝐩𝐫𝐨𝐛𝐥𝐞𝐦: 𝐂𝐨𝐦𝐛𝐢𝐧𝐚𝐭𝐢𝐨𝐧 𝐒𝐮𝐦 🔹 Problem Summary: Given an array of distinct integers and a target, find all unique combinations where the numbers sum up to the target. Each number can be used multiple times. 🔹𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡 𝐔𝐬𝐞𝐝: I solved this using Backtracking (Recursion). . Try including the current element . Explore further combinations . Backtrack and try excluding it . Stop when sum exceeds target 🔹 Key Learning: Backtracking helps in exploring all possible combinations efficiently by building solutions step-by-step and undoing choices when needed. #Day97 #100DaysOfCode #LeetCode #Java #DSA #Backtracking #CodingJourney
To view or add a comment, sign in
-
-
Day: 96/365 📌 LeetCode POTD: Minimum Distance to Type a Word Using Two Fingers Hard Key takeaways/Learnings from this problem: 1. This problem is a great example of DP with state as both fingers’ positions, which feels tricky at first but clicks once you model it right. 2. Key learning: instead of deciding both fingers every time, fix one and optimize the movement of the other to reduce complexity. 3. Precomputing distances between characters makes transitions much faster and keeps the code clean. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
To view or add a comment, sign in
-
-
Day 17 of #100DaysOfCode Solved Plus One (Easy) today. A simple but important problem that reinforces handling edge cases carefully. Key Idea: Traverse from the last digit, handle carry properly. Approach: Start from the end of the array If digit < 9 → increment and return If digit == 9 → make it 0 and carry forward If all digits are 9 → create new array with leading 1 Learning: Even the easiest problems test your attention to edge cases. Consistency > Complexity. #LeetCode #DSA #CodingJourney #Java #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 81 of #LeetCode Journey Solved: Subarray Sums Divisible by K Today’s problem helped me understand the power of Prefix Sum + HashMap optimization. 💡 Key Learning: Instead of checking all subarrays (O(n²)), we can use modulo + frequency map to reduce it to O(n). If two prefix sums have the same remainder, the subarray between them is divisible by K. 🧠 Concepts used: Prefix Sum Modulo Arithmetic HashMap (Frequency Count) ✅ Result: Accepted ✔️ Consistency is building confidence day by day 💪 #Day81 #DSA #Java #LeetCode #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🔥 Day 61 of #100DaysOfCode Solved – Contains Duplicate II 🔍 What I did: Used a sliding window approach with a HashSet to track elements within a range of size k, checking for duplicates efficiently. 💡 Key Learning: Understood the concept of sliding window technique Learned how to use HashSet for quick duplicate checks Practiced controlling window size by removing outdated elements 🎯 Takeaway: Combining sliding window with hashing helps solve problems efficiently without extra complexity. #Day61 #LeetCode #Java #ProblemSolving #CodingJourney #100DaysOfCode #DSA
To view or add a comment, sign in
-
-
Today’s progress in my DSA journey 🚀 I focused on Bit Manipulation and learned some really powerful operations: 🔹 Update i-th bit – How to change a specific bit to 0 or 1 efficiently 🔹 Clear i-th bit – Removing a bit at a given position using bit masking 🔹 Clear range of bits (i to j) – Learned how to reset multiple bits in a range with a single operation 🔹 Clear last i bits – Useful trick to zero out bits from the least significant side Bit manipulation feels tricky at first, but once the logic clicks, it becomes super efficient and elegant 💡 Consistency is the goal. Small steps every day. #DSA #Java #BitManipulation #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
Day 5 / 100 Days of Coding : Solved: Best Time to Buy and Sell Stock Today’s problem looked simple but taught a powerful concept — tracking minimums and maximizing profit in a single pass. Key Learning: Instead of checking all pairs (which is slow), we maintain: Minimum price so far Maximum profit so far This reduces complexity from O(n²) → O(n) Consistency is the real game. Showing up every day matters more than perfection. #100DaysOfCode #DSA #LeetCode #Java #CodingJourney #ProblemSolving #GreedyAlgorithm
To view or add a comment, sign in
-
-
🚀 Day 32/100 Continuing My DSA Journey Worked on some core Linked List problems today: 🔹 Reverse Linked List 🔹 Remove Linked List Elements 🔹 Remove Duplicates from Sorted List What I focused on: ✅ Solving without using a dummy node ✅ Handling edge cases like deleting the head ✅ Managing prev and current pointers correctly Key learning 💡 👉 In linked list deletion, move prev only when you are NOT deleting. Also understood how avoiding a dummy node makes you think more carefully about pointer handling and edge cases. Step by step, building strong fundamentals. 🔥 #DSA #LinkedList #Java #LeetCode #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 126/500 – LeetCode DSA Challenge Today I solved problems focused on strings and frequency counting. ✅ Ransom Note – Used frequency array to check if the note can be constructed from magazine characters. TC: O(n + m) | SC: O(1) ✅ Find Common Characters – Iteratively found common characters across all strings using string manipulation. TC: O(n × k) | SC: O(k) 💡 Key Learning: Frequency counting is a powerful technique for string problems, and careful string manipulation helps in handling character intersections. 👉 Day 126/500 #DSA #Java #500DaysChallenge #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
60-Day LeetCode Challenge – Day 40 Solved Check if All Characters Have Equal Number of Occurrences on LeetCode. 📌 Approach: Used a frequency array (size 26) to count occurrences of each character, then compared all non-zero frequencies with an expected value. 🧠 Learning: Reinforced frequency counting patterns — a super common technique in string problems. ⚡ Complexity: • Time Complexity: O(n) • Space Complexity: O(1) Starting to see patterns repeat across problems — that’s when things begin to click ⚡ #LeetCode #DSA #Java #Strings #Consistency #ProblemSolving
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