🚀 Day 28/60 — LeetCode Discipline Problem Solved: Number of 1 Bits (Hamming Weight) Difficulty: Easy Today’s problem explored the fundamentals of bit manipulation, one of the most powerful and efficient areas in programming. The task was to count the number of set bits (1s) in the binary representation of a number. Instead of converting the number to a binary string, the solution uses bitwise operations to efficiently extract each bit. This approach highlights how low-level operations can lead to high-performance solutions with minimal overhead. 💡 Focus Areas: • Strengthened bit manipulation concepts • Practiced use of bitwise AND (&) • Understood right shift operations (>>>) • Improved efficiency by avoiding extra space • Built deeper understanding of binary representation ⚡ Performance Highlight: Achieved 0 ms runtime (100% performance). Mastering bits is like learning the language of machines — once you understand it, everything becomes faster and sharper. #LeetCode #60DaysOfCode #100DaysOfCode #DSA #BitManipulation #Algorithms #ProblemSolving #CodingJourney #SoftwareEngineering #Java #Developers #TechGrowth #Consistency #LearnToCode
LeetCode Discipline: Number of 1 Bits in Binary Representation
More Relevant Posts
-
Day 78 - LeetCode Journey Solved LeetCode 142: Linked List Cycle II (Medium) today — a powerful extension of the cycle detection problem. Earlier, we learned how to detect if a cycle exists. Now the challenge is to find the exact node where the cycle begins. 💡 Core Idea (Floyd’s Algorithm Extended): 1) Use slow & fast pointers to detect a cycle 2) Once they meet, reset one pointer to the head 3) Move both pointers one step at a time 4) The point where they meet again = start of the cycle 🤯 Why it works? Because of the mathematical relationship between distances traveled inside the cycle — both pointers align perfectly at the cycle entry point. ⚡ Key Learning Points: • Advanced use of two-pointer technique • Understanding the mathematics behind cycle detection • Solving without modifying the list • Maintaining O(n) time and O(1) space This is not just coding — this is algorithmic thinking at a deeper level. Also, this pattern connects with: -> Find duplicate number (cycle in array) -> Happy Number problem -> Loop detection in graphs ✅ Stronger conceptual clarity ✅ Better problem-solving depth ✅ Confidence with tricky pointer problems From detecting a cycle to pinpointing its start — that’s real progress 🚀 #LeetCode #DSA #Java #LinkedList #TwoPointers #Algorithms #ProblemSolving #CodingJourney #Consistency #100DaysOfCode #InterviewPreparation #DeveloperGrowth #KeepCoding
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 54 of Practicing DSA (LeetCode && Competitive Programming) Today’s progress: LeetCode • Maximum Product Subarray – Medium Focused on: • Understanding Kadane’s Algorithm variation • Tracking both maximum and minimum product (due to negative numbers) • Handling sign changes effectively • Improving intuition for dynamic programming in arrays This problem deepened my understanding of how negative values impact subarray problems. Competitive Programming • Continued practicing problem-solving patterns Improved my thinking on: • Handling edge cases in array-based problems • Writing optimized solutions with better logic clarity Daily progress may look small, but it’s building strong fundamentals 💪 Consistency is the real game 🔥 #DSA #Java #LeetCode #Codeforces #DynamicProgramming #Arrays #ProblemSolving #Consistency #Learnin
To view or add a comment, sign in
-
-
🚀 Day 12 of #30DaysOfCode Back to Learning ! Today I explored a cool concept: 👉 Adding two integers without using the + operator in Python! Instead of +, I used bitwise operations: 🔹 XOR (^) → gives the sum without carry 🔹 AND (&) + LEFT SHIFT (<<) → handles the carry 💻 Code: def add_without_plus(a, b): while b != 0: carry = a & b # common bits (carry) a = a ^ b # sum without carry b = carry << 1 # shift carry to the left return a🧠 How it works: ✔️ XOR adds bits where only one is 1 ✔️ AND finds carry bits ✔️ Shift carry left and repeat until no carry remains 📌 Example: For 5 + 3: 5 = 101 3 = 011 ---------- XOR = 110 (6) AND = 001 → carry = 010 (after shift) Repeat until carry = 0 → result = 8 → Final Result = 8 ✅ ✨ This helped me understand how addition actually works at the binary level! #Python #Coding #30DaysOfCode #Programming #Bitwise #Learning #TechJourney
To view or add a comment, sign in
-
🚀 Day 53 of #100DaysOfLeetCode Solved: Next Greater Element (Leetcode 496) Today’s problem was a great reminder of how powerful Monotonic Stack can be for optimization. 🔹 Approach: Used a stack to maintain decreasing elements Mapped each element to its next greater using a HashMap Reduced time complexity from O(n²) → O(n) 🔹 Key Learning: Small mistakes in conditions (like missing a !) can completely break logic. Attention to detail matters just as much as understanding the concept. 🔹 Complexity: Time: O(n + m) Space: O(n) Consistency > Perfection. Showing up daily and improving step by step. #LeetCode #DSA #Java #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
Day 51 of My 90-Day Coding Challenge Today’s focus was on recursion, and honestly — it’s not as simple as it looks. I solved Letter Combinations of a Phone Number, which seems straightforward at first, but quickly tests how well you actually understand recursive thinking. The real challenge wasn’t writing code — it was thinking in terms of: • Breaking the problem into smaller subproblems • Building combinations step by step • Managing the recursive flow correctly Key learning: Recursion is not about memorizing patterns — it’s about visualizing the decision tree and trusting the process. One mistake I noticed: If you don’t clearly understand the base case and transitions, recursion becomes confusing very fast. What improved today: • Better clarity on how combinations are formed • Stronger grip on recursion structure (index + choices) • More confidence in handling backtracking-style problems Hard truth: Recursion feels difficult because the thinking is different — not because the problem is hard. And that’s exactly why it’s important to master it. #90DaysOfCode #DSA #Java #Recursion #Backtracking #LeetCode #ProblemSolving
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 13/100 – LeetCode DSA Challenge 🔹 Problem Solved: 238. Product of Array Except Self Today’s problem was a great exercise in array manipulation and optimization. 📌 Problem Summary: Given an array nums, return a new array where each element is the product of all elements except itself. 📊 Example: Input: [1,2,3,4] Output: [24,12,8,6] 💡 What I Learned: How to handle edge cases like zeros in an array Importance of time complexity O(n) Why some solutions (like division) are not always valid Concept of prefix & suffix products (optimal approach) ⚠️ Challenge: Cannot use division Must solve in linear time 🧠 My Approach: First tried using total product and division Faced issues with zero values (division by zero error) Improved the logic by handling zero cases carefully 🔥 Key Insight: If there is: More than 1 zero → all outputs = 0 Exactly 1 zero → only that index gets product No zero → normal calculation works 📈 Next Goal: Learn and implement the optimal solution without division (prefix + suffix method) #Day13 #100DaysOfCode #LeetCode #DSA #Java #CodingJourney #ProblemSolving #FutureDeveloper
To view or add a comment, sign in
-
-
🚀 Day 10 of 100 Days LeetCode Challenge Problem: Find All Possible Stable Binary Arrays II Today’s problem is an extension of Day 9—but with optimized Dynamic Programming ⚡ 💡 Key Insight: Same constraints: Fixed number of 0s and 1s No more than limit consecutive identical elements 👉 Which means: We must carefully control streak length And efficiently count all valid combinations 🔍 Approach (Optimized DP): Use DP + Prefix Sum Optimization State includes: Count of 0s used Count of 1s used Ending with 0 or 1 💡 Optimization: Instead of recalculating ranges repeatedly, use prefix sums This reduces time complexity significantly 👉 Apply modulo (10⁹ + 7) for large answers 🔥 What I Learned Today: Same problem can have multiple levels of optimization Prefix sum is powerful in reducing DP transitions Moving from brute → DP → optimized DP is real growth 📈 📈 Challenge Progress: Day 10/100 ✅ Double digits achieved! LeetCode, Dynamic Programming, Prefix Sum, Optimization, Combinatorics, Binary Arrays, DSA Practice, Coding Challenge, Problem Solving #100DaysOfCode #LeetCode #DSA #CodingChallenge #DynamicProgramming #PrefixSum #Optimization #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
To view or add a comment, sign in
-
-
🚀 Day 16 of My LeetCode Journey Today, I solved LeetCode Problem #747 – Largest Number At Least Twice of Others. 🔍 Problem Summary: Given an array of integers, we need to find whether the largest element is at least twice as much as every other number. If yes, return its index; otherwise, return -1. 💡 Approach I Used: First, find the largest and second largest elements in the array. Then check if the largest element is at least twice the second largest. If yes, return the index of the largest element. 🧠 Key Learning: This problem improved my understanding of: Array traversal Maintaining multiple variables (max & second max) Writing optimized O(n) solutions 📈 Progress: Consistency is the key 🔑 — improving step by step every day. #LeetCode #DSA #Java #CodingJourney #ProblemSolving #100DaysOfCode
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