🔥 Day 142/360 – Learning Something New Today 🚀 Most people miss this simple trick… But once you understand it, problems become much easier 👇 📌 Topic: Bit Manipulation 🧩 Problem: Single Number II 📝 Problem Statement: Find the element that appears once when all others appear three times 🔍 Example: Input: [2, 2, 3, 2] Output: 3 💡 Approach: Bit Manipulation (Bit Counting) ✔ Step 1 – Traverse all 32 bit positions ✔ Step 2 – Count how many numbers have that bit set ✔ Step 3 – If count % 3 == 1, set that bit in answer ⚡ Key Idea: Duplicate numbers contribute bits in multiples of 3, so taking modulo 3 isolates the unique number ⏱ Complexity: Time → O(n) Space → O(1) 📚 What I Learned: Bit-level thinking can simplify problems that look complex with normal counting 💬 Question for You: Can you solve this problem using XOR without counting bits? 🤔 #DSA #Java #Coding #ProblemSolving #InterviewPrep #LeetCode #TechJourney #142DaysOfCode
Bit Manipulation Trick for Single Number Problem
More Relevant Posts
-
Day 22/100 — LeetCode Today’s problem: Happy Number 😊 At first, it looked like a simple math problem… but it turned out to be about patterns and repetition. 🔍 What I learned: Break a number into digits using % 10 and / 10 Square each digit and keep adding Repeat the process until: You reach 1 → Happy Number ✅ Or it starts repeating → Not Happy ❌ 🧠 Key Insight: This problem is actually about cycle detection — if a number repeats, it will never reach 1. ⚡ Simple Example: 19 → 82 → 68 → 100 → 1 ✅ 💡 Takeaway: Sometimes problems that look like math are really about loops and patterns. Small steps every day → Big improvement 🚀 #Day22 #100DaysOfCode #LeetCode #Java #DSA #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 56 of #100DaysOfLeetCode Solved: Longest Substring Without Repeating Characters Today’s problem really tested my understanding of the sliding window technique. 🔹 Key Learning: Instead of restarting the window when a duplicate appears, I used a HashMap to track the last index of characters and moved the left pointer smartly using Math.max(). This helped maintain an optimal window without unnecessary rework. 🔹 Approach: Used two pointers (left & right) Stored last seen index of each character Adjusted window dynamically to avoid duplicates 🔹 Complexity: Time: O(n) Space: O(n) This problem made me realize how important it is to truly understand pointer movement rather than just memorizing patterns. Slowly building consistency and clarity, one problem at a time. #LeetCode #DSA #Java #CodingJourney #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
Day 19 of #100DaysOfCode Solved “Base 7” problem today — a simple yet insightful exercise on number systems. 💡 Approach: Convert the integer into base 7 by repeatedly dividing by 7 and storing remainders. Handle negative numbers separately and reverse the result at the end. ⚡ Key Learning: Even easy problems strengthen fundamentals like loops, math logic, and edge case handling. Consistency > Complexity. #LeetCode #DSA #CodingJourney #Java #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
DSA Practice Update Today I solved: #78 – Subsets Learned the backtracking approach to generate all possible subsets (power set). Understood how to explore both choices at each step: including or excluding an element, and how to use recursion with backtracking to build all combinations. Key Learnings: • Introduction to backtracking technique • Recursion with decision making (pick / not pick) • Building combinations step by step This problem helped me understand the fundamentals of backtracking, which is an important concept for many interview problems. Continuing to stay consistent and strengthen core concepts. #DSA #LeetCode #CodingJourney #Java #SoftwareDevelopment #PlacementPreparation
To view or add a comment, sign in
-
-
✅ 𝘿𝙖𝙮 6 𝙋𝙧𝙤𝙜𝙧𝙚𝙨𝙨: 🔹Solved the 𝗠𝗮𝗷𝗼𝗿𝗶𝘁𝘆 𝗘𝗹𝗲𝗺𝗲𝗻𝘁 problem using the 𝗕𝗼𝘆𝗲𝗿-𝗠𝗼𝗼𝗿𝗲 𝗩𝗼𝘁𝗶𝗻𝗴 𝗔𝗹𝗴𝗼𝗿𝗶𝘁𝗵𝗺. 🔹Strengthened understanding of 𝗰𝗮𝗻𝗱𝗶𝗱𝗮𝘁𝗲 𝘀𝗲𝗹𝗲𝗰𝘁𝗶𝗼𝗻 and how majority elements survive pairwise cancellation. 🔹Practiced using a 𝘀𝗶𝗻𝗴𝗹𝗲 𝘁𝗿𝗮𝘃𝗲𝗿𝘀𝗮𝗹 to solve the problem in optimal time complexity. 🔹Improved understanding of maintaining a 𝗰𝗼𝘂𝗻𝘁𝗲𝗿 and resetting the candidate when count becomes zero. 🔹Focused on solving array problems with 𝗢(𝗻) 𝘁𝗶𝗺𝗲 and 𝗢(𝟭) 𝘀𝗽𝗮𝗰𝗲 complexity. 🔹Learned how smart observation can replace brute force nested loop approaches. #DSA #100DaysOfCode #LeetCode #CodingJourney #ProblemSolving #Java #Learning
To view or add a comment, sign in
-
-
🚀 Day 11/100 — #100DaysOfLeetCode Consistency continues — one problem closer to better problem-solving skills 💻🔥 ✅ Problem Solved: 🔹 LeetCode 1423 — Maximum Points You Can Obtain from Cards 💡 Concepts Used: Sliding Window Technique Complementary Subarray Thinking 🧠 Key Learning: Instead of directly choosing k cards from both ends, I learned to think differently — find the minimum sum subarray of size n - k and subtract it from the total sum. This transformation converts a complex decision problem into a clean sliding window optimization. ⚡ Takeaway: Sometimes optimization comes from changing perspective, not increasing complexity. Continuing the journey 🚀 #100DaysOfLeetCode #LeetCode #DSA #SlidingWindow #Algorithms #Java #ProblemSolving #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
-
“What I learned after solving 300+ LeetCode problems 👇” At the beginning, I made a mistake. I kept solving random problems every day thinking: “More problems = more skill” But I was wrong. I realized that solving problems randomly is mostly a waste of time if you don’t understand the pattern behind them. Everything changed when I started focusing on patterns instead of problems. Here are some important patterns I learned: • Sliding Window • Two Pointers • Prefix Sum • Binary Search • Recursion & Backtracking • Linked List Patterns • Stack & Monotonic Stack • Hashing / Frequency Count Once you understand these patterns: You don’t need to solve 1000 problems. You start recognizing solutions instantly. Now when I see a problem, I don’t panic. I ask: 👉 “Which pattern does this belong to?” That one question changed everything for me. Still learning, but now with direction 🚀 #DSA #LeetCode #Java #BackendDevelopment #CodingJourney
To view or add a comment, sign in
-
🚀 Day 69/100 Today, I worked on an interesting problem: Reverse Degree of a String 💡 What I learned: • How to map characters using the reversed alphabet (a = 26 → z = 1) • Applying ASCII concepts for character calculations • Importance of 1-based indexing in problem-solving • Strengthened my logic-building with simple math + strings 🧠 Approach: Iterated through the string, calculated each character’s reversed value, multiplied it with its position, and summed it up. ⚡ Time Complexity: O(n) 📦 Space Complexity: O(1) ✨ Key Takeaway: Even simple problems help in sharpening fundamentals and improving problem-solving speed. Consistency is the real game changer! #Day69 #DSA #Java #CodingJourney #ProblemSolving #Consistency #KeepLearning
To view or add a comment, sign in
-
-
DSA Practice Update Today I solved: #141 – Linked List Cycle Learned how to detect a cycle in a linked list using Floyd’s Cycle Detection Algorithm (fast and slow pointers). Understood how moving pointers at different speeds helps identify if a loop exists without using extra space. Key Learnings: • Fast and slow pointer technique • Detecting cycles efficiently in O(n) time • Solving problems with constant space complexity This problem strengthened my understanding of pointer-based approaches, which are commonly used in linked list interview questions. Continuing to stay consistent and improve problem-solving skills step by step. #DSA #LeetCode #CodingJourney #Java #SoftwareDevelopment #PlacementPreparation
To view or add a comment, sign in
-
-
DSA Day 20 – Frequency Counting with Strings Today I solved the “Ransom Note” problem on LeetCode. Problem: Check whether the ransomNote string can be constructed using letters from the magazine string, where each letter can be used only once. Approach Used: -> Counted frequency of characters in ransomNote -> Counted frequency of characters in magazine -> Compared required characters with available characters -> If any required count was greater than available count → false Time Complexity: -> O(n + m) Space Complexity: -> O(1) (Only lowercase English letters / limited character set) Key Learning: -> Frequency counting works not only for arrays, but also for strings -> HashMap helps compare required vs available resources efficiently -> Always check constraints, because they can reduce space complexity What I Realized: Many string problems are actually counting problems in disguise. The better you recognize patterns, the faster you solve problems. Thanks to Pulkit Aggarwal sir for guiding me in DSA and helping me understand problem-solving patterns. Consistency continues, one problem every day. #DSA #LeetCode #Java #ProblemSolving #CodingJourney #100DaysOfCode
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