🚀 Day 90 of #100DaysOfCode | LeetCode Daily Solved LeetCode Problem #401 – Binary Watch ⌚💻✅ A fun problem that blends bit manipulation with simple iteration. The idea is to count set bits for hours and minutes and generate all valid time combinations. Key Takeaways: -> Smart use of Integer.bitCount() for counting LEDs -> Separating hours (0–11) and minutes (0–59) cleanly -> Formatting time output correctly (leading zeros matter!) -> Brute force done right with clear constraints Language: Java -> Runtime: 3 ms (Beats 91.19%) -> Memory: 43.45 MB (Beats 94.31%) Consistency builds confidence. 90 days in — still pushing forward. 🔥💻 #LeetCode #Java #BitManipulation #BinaryWatch #ProblemSolving #100DaysOfCode
LeetCode 401 Binary Watch Solution in Java
More Relevant Posts
-
🚀 Day 91 of #100DaysOfCode | LeetCode Daily Solved LeetCode Problem #693 – Binary Number with Alternating Bits 🔢💡✅ A clean and elegant bit manipulation problem. The trick is to XOR the number with its right shift and check if the result becomes all 1s — simple, fast, and effective. Key Takeaways: -> Using n ^ (n >> 1) to detect alternating patterns -> Leveraging highestOneBit() for boundary checks -> Writing concise, branch-free logic with bitwise ops -> Sometimes the smartest solutions are the shortest Language: Java -> Runtime: 0 ms (Beats 100%) -> Memory: 41.81 MB (Beats 97.08%) One more day, one more concept sharpened. 🔥 Onward to Day 92 💻🚀 #LeetCode #Java #BitManipulation #BinaryNumbers #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 38 of #100DaysOfLeetCode Today I solved "Container With Most Water" problem on LeetCode. 🔹 Difficulty: Medium 🔹 Concept Used: Two Pointer Technique 🔹 Language: Java 📌 Problem Summary: Given an array representing heights of vertical lines, the goal is to find two lines that together with the x-axis can contain the maximum amount of water. 💡 Approach: Instead of checking all possible pairs (O(n²)), I used the Two Pointer approach which reduces the time complexity to O(n). Steps: 1️⃣ Start with two pointers at the beginning and end of the array. 2️⃣ Calculate the area using the smaller height. 3️⃣ Move the pointer with the smaller height inward. 4️⃣ Track the maximum area during each step. 📊 Result: ✅ Runtime: 5 ms (Beats 81.86%) ✅ Memory: Beats 95.54% This problem was a great exercise to understand optimization using two pointers instead of brute force. Consistency is the key — moving forward one problem at a time! 💪 #LeetCode #100DaysOfCode #Java #DSA #CodingChallenge #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 8 Today I solved “Check if Binary String Has at Most One Segment of Ones” on LeetCode. At first glance, the problem looks simple: Given a binary string, check whether it contains only one continuous segment of '1's. Example: "110" → Valid (one segment of 1s) "1001" → Invalid (two separate segments of 1s) While solving it, I realized an interesting observation: 👉 If a binary string has more than one segment of 1s, the pattern "01" must appear before another "1". So instead of counting segments explicitly, we can simply check whether '01' appears and is followed by another '1'. This turns the problem into a very efficient linear scan with O(n) time complexity. 💡 Key takeaway: Sometimes the simplest solution comes from recognizing patterns in the string rather than simulating the whole process. Also happy to see my solution running at 0 ms runtime (100% faster) 🚀 #LeetCode #DSA #ProblemSolving #Java #CodingJourney #BinaryStrings
To view or add a comment, sign in
-
-
🚀 Day 13 of #LeetCode Challenge 🔢 Problem: 1758 – Minimum Changes To Make Alternating Binary String Today’s problem was about converting a binary string into an alternating pattern with minimum changes. 💡 Key Insight: An alternating string can only start with either ‘0’ or ‘1’. So instead of trying many possibilities, I compared both patterns and counted mismatches — then returned the minimum. ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(1) ✨ This problem improved my thinking in: Pattern observation Optimization approach Writing clean and efficient Java code Consistency > Motivation 💪 #Day13 #Java #DSA #LeetCode #CodingJourney #FutureFullStackDeveloper
To view or add a comment, sign in
-
-
🚀 Day 98 of #100DaysOfCode Solved LeetCode #1356 – Sort Integers by The Number of 1 Bits ✅ A clean bit manipulation + sorting problem that rewards thinking beyond plain comparisons. Key Takeaways: -> Using Integer.bitCount() to count set bits efficiently -> Encoding sort priority directly into values for simplicity -> Leveraging built-in sorting for clean and fast solutions -> Small tricks can lead to elegant code ✨ Language: Java -> Runtime: 6 ms (Beats 93.70%) ⚡ -> Memory: 47.42 MB Almost there. Staying consistent till the end 💻🔥 #LeetCode #Java #BitManipulation #Sorting #ProblemSolving #DSA #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Cracked LeetCode 189 – Rotate Array using an optimized in-place approach. Instead of brute force (O(n × k)), I implemented the reverse algorithm technique to achieve: ✅ Time Complexity: O(n) ✅ Space Complexity: O(1) ✅ 0 ms runtime (Beats 100%) Focused on improving optimization thinking and writing clean, efficient Java code. #LeetCode #Java #DataStructures #Algorithms #ProblemSolving #TechGrowth
To view or add a comment, sign in
-
-
Day 2/100 – LeetCode Challenge 🚀 Problem: #48 Rotate Image Difficulty: Medium Language: Java Approach: In-Place Rotation using Transpose + Row Reversal Time Complexity: O(n²) Space Complexity: O(1) 🔍 Key Insight: To rotate a matrix 90° clockwise without extra space: 1️⃣ First transpose the matrix (swap across diagonal). 2️⃣ Then reverse each row. This avoids creating a new matrix and satisfies the in-place constraint. 🧠 Solution Brief: Used nested loops to transpose the matrix by swapping arr[i][j] and arr[j][i]. Then reversed each row using two pointers (start and end). Combined both operations inside a rotate() method. Achieved full rotation with constant extra space. 📌 What I Learned: Matrix problems are more about pattern recognition than brute force. Understanding transformations (transpose + reverse) makes complex problems simple. Starting my 100 Days of LeetCode journey today 💪 Consistency > Motivation. #LeetCode #Day2 #100DaysOfCode #Java #DSA #Matrix #ProblemSolving #CodingJourney #MediumProblem
To view or add a comment, sign in
-
-
🚀 Day 20/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 350. Intersection of Two Arrays II Used sorting + two-pointer technique to efficiently find common elements appearing in both arrays while maintaining correct frequency. ⏱️ Time Complexity: O(n log n + m log m) 📦 Space Complexity: O(min(n, m)) (for storing the intersection) Strengthening understanding of array traversal and two-pointer pattern through consistent practice. 💪 Consistency keeps the progress moving 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Leetcode Problem || Number of Steps to Reduce a Number in Binary Representation to One(1404)🚀 Today I solved a binary manipulation problem where we must: If number is even → divide by 2 If odd → add 1 Count steps until number becomes 1 💡 Learned: How to simulate binary addition using carry Avoid integer overflow Optimize string-based numeric problems #Java #DSA #BitManipulation #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 31/180 | #180DaysOfCode 📍 LeetCode | 💻 Java Solved: 69. Sqrt(x) Used the Binary Search approach to find the integer square root without using built-in power functions. The search space is reduced by checking mid * mid against x. ⏱️ Time Complexity: O(log n) 📦 Space Complexity: O(1) Strengthening problem-solving skills with binary search patterns on answer space. 💪 Consistency continues 🚀 #DSA #LeetCode #Java #CodingJourney #Consistency
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