🗓 Day 12 / 100 – #100DaysOfLeetCode 📌Problem 3234: Count the Number of Substrings With Dominant Ones A substring is considered to have dominant ones if: Number of 1s ≥ (Number of 0s)² The challenge was to count how many substrings in the binary string satisfy this condition. 🧠 My Approach: Iterated through substrings while tracking zero count and one count. Used the condition ones ≥ zeros² to determine validity. Applied early stopping when zeros became large, since the condition becomes much harder to meet as zeros grow. This pruning helped avoid unnecessary checks and made the approach more efficient. 💡 Key Learning: This problem highlights how mathematical constraints can simplify substring evaluation. Understanding how zeros grow quadratically in the condition helped shape a smarter, more optimized checking approach rather than brute-force enumeration. A great exercise in reasoning about substring properties and designing early-exit logic. Consistent effort… consistent progress 🚀 #100DaysOfLeetCode #LeetCodeChallenge #Python #ProblemSolving #BinaryStrings #StringAlgorithms #Optimization #LogicBuilding #DataStructures #Algorithms #DSA #CompetitiveProgramming #CodingJourney #SoftwareEngineering #LearningInPublic #TechStudent #DeveloperJourney #CareerGrowth #CodeEveryday #CodingCommunity #KeepLearning #Programmer
Counting Dominant Ones Substrings in Binary Strings
More Relevant Posts
-
🗓 Day 13 / 100 – #100DaysOfLeetCode 📌 Problem 1513: Number of Substrings With Only 1s The task was to count how many substrings in a binary string consist only of consecutive 1s. 🧠 My Approach: Identified continuous blocks of '1' in the string. For each block of length k, calculated the number of valid substrings using the formula: k × (k + 1) / 2 Summed these counts across all segments of consecutive 1s. This avoids checking all substrings individually and keeps the solution efficient and clean. 💡 Key Learning: This problem reinforces the value of recognizing sequences and using mathematical formulas to simplify substring counting. It’s a reminder that many problems can be solved much faster when we look for structure instead of brute force. One more problem, one more pattern learned 🚀 #100DaysOfLeetCode #LeetCodeChallenge #Python #ProblemSolving #Strings #Algorithms #MathInCoding #LogicBuilding #DataStructures #DSA #CompetitiveProgramming #CodingJourney #SoftwareEngineering #LearningInPublic #DeveloperJourney #TechStudent #CareerGrowth #CodeEveryday #CodingCommunity #KeepLearning
To view or add a comment, sign in
-
-
🔥 Day 96 of #100DaysOfDSA – Power of Three 💡 📌 Problem. no 326: Check if a given number is a power of 3. If it is, return True; otherwise, return False. Simple yet elegant number theory logic at play. 🚀 Runtime: 11 ms – Beats ⚡61.54% of Python submissions 💾 Memory: 12.45 MB – Beats 51.93% 💻 Language: Python ✅ Result: Accepted – 21,040 / 21,040 test cases passed! 🔑 Key Learnings ✔️ Efficient looping and modular arithmetic can reveal hidden mathematical patterns ✔️ Edge cases (like n <= 0) must always be handled carefully ✔️ Clean, readable code performs just as powerfully as optimized code 🎯 Day 96 — Mathematics + Logic = Pure Programming Magic ✨ #100DaysOfCode #100DaysOfDSA #LeetCode #PythonProgramming #DataStructures #AlgorithmPractice #CodeNewbie #DailyCoding #ProblemSolving #TechJourney #WomenWhoCode #CodeLife #CodingChallenge #DSAChallenge #DeveloperLife #PythonDeveloper #LearnToCode #CodingCommunity #CodeEveryday #SoftwareEngineering #KathirCollegeOfEngineering #KathirCollege #BTechLife #AIDS #FutureEngineer #CodingMotivation #ProgrammingSkills
To view or add a comment, sign in
-
-
Day 30 / 100 – Majority Element II (LeetCode #229) Today’s challenge was all about identifying numbers that appear more than ⌊ n/3 ⌋ times in an array. This problem was a great way to explore the Boyer–Moore Voting Algorithm, an elegant and efficient method to find potential majority elements without using extra space. 🔍 Key Learnings Understanding how counters and candidates evolve in an iterative approach Strengthening logic for pattern recognition and frequency analysis Realizing how efficient algorithms can reduce time and memory usage 💭 Thought of the Day Consistency isn’t just about showing up — it’s about learning smarter each day. Every new problem isn’t a repetition; it’s a refinement of logic and discipline. 🔗 Problem Link:https://lnkd.in/gfiGVueC #100DaysOfCode #Day30 #LeetCode #Python #ProblemSolving #CodingChallenge #DataStructures #Algorithms #LearningJourney #CodeEveryday #TechGrowth
To view or add a comment, sign in
-
-
💻 2011: Final Value of Variable After Performing Operations Today’s challenge was a simple yet interesting warm up problem that tests how efficiently we can track changes in a variable through a series of operations. 🧠 Concept: We start with X = 0, and perform operations like ++X, X++, --X, and X--. Each increment or decrement modifies X by 1, the task is to return the final value after performing all operations. ⚙️ Approach: - A straightforward solution: - Iterate through all operations. - Increment count by 1 for ++ or X++. - Decrement count by 1 for -- or X--. - Return the final count. Even though it’s an easy problem, it’s a great reminder that clarity and precision matter, small details in logic can make a big difference. #LeetCode #Python #CodingPractice #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🔍 Day 44 DSA Challenge – Problem #33: Search in Rotated Sorted Array 📌 Problem Statement: Given a sorted array nums that may have been rotated at an unknown pivot, find the index of a target value. Return -1 if the target doesn’t exist. The solution must run in O(log n) time. ⚙️ How I Solved It: Applied a modified binary search: Identify which half (left or right) is sorted. Narrow the search to the half where the target could exist. Repeat until the target is found or search space is exhausted. 📊 Performance Stats: ⏱ Runtime: 0 ms (⚡ beats 100%) 💾 Memory: 12.65 MB (beats 42.49%) ✅ Testcases Passed: 196 / 196 🧠 Key Takeaway: Understanding array properties like rotation and leveraging binary search ensures optimal search performance in logarithmic time. #LeetCode #BinarySearch #RotatedArray #Problem33 #Python #DSA #100DaysOfCode #CodingJourney
To view or add a comment, sign in
-
-
✨ Leetcode #3370: Smallest Number With All Set Bits Today, I solved an interesting bit manipulation problem where the task was to find the smallest number greater than or equal to a given n, such that its binary representation contains only set bits (1s). 🔍 Concept Overview: - This problem beautifully highlights the power of bit manipulation and mathematical insight. - The key lies in observing the pattern of numbers that have all bits set, like 1, 3, 7, 15, 31, etc. - These numbers can be represented in a uniform mathematical form, which makes the solution both elegant and efficient. 💡 Key Learning: - Understanding how bit shifting and logarithmic operations can simplify problems involving binary representations. - Reinforcing the importance of pattern recognition in bit level problems. - Appreciating how a constant time solution can emerge from strong mathematical reasoning. 🧠 Complexity: O(1) A pure logic based solution; concise, optimal, and satisfying! #LeetCode #BitManipulation #Coding #ProblemSolving #Python #LearningEveryday #DataStructuresAndAlgorithms
To view or add a comment, sign in
-
-
🚀 Day 40 of #100DaysOfDSA Solved LeetCode Problem #69 – Sqrt(x) 🧮 💡 Problem Insight: Given a non-negative integer x, return the square root of x rounded down to the nearest integer. For example: Input: x = 8 Output: 2 (since √8 ≈ 2.828, and floor(2.828) = 2) ✨ Key Learnings: Practiced binary search to find results efficiently without using built-in math functions. Learned how to narrow down search space based on mid-square comparisons. Reinforced understanding of integer division and rounding down behavior. Time Complexity: O(log n) — fast and efficient! Space Complexity: O(1) 💬 Lesson: Binary Search isn’t just for sorted arrays — it’s a mindset for narrowing down possibilities quickly 🚀 #LeetCode #Python #DSA #BinarySearch #ProblemSolving #100DaysOfCode #Day40 #CodingJourney
To view or add a comment, sign in
-
-
🔁 Day 45 of #100DaysOfDSA — Reverse Linked List Problem: Reverse Linked List (LeetCode #206) Given the head of a singly linked list, reverse it and return the reversed list. Concepts Used: 🧠 Stack-based approach Traverse the linked list and push each node’s value into a stack. Then reassign values by popping from the stack to reverse the list. 🧩 Learning Reflection: This problem helped me understand how stacks can simplify linked list manipulations. Though not the most space-efficient solution, it reinforces the concept of LIFO (Last In, First Out) operations beautifully. ⏱️ Complexity: Time: O(N) Space: O(N) 💬 Closing Thought: Sometimes, using an extra data structure makes logic clearer — and that’s okay while learning. #LeetCode #DSA #LinkedList #Python #100DaysOfCode #CodingJourney
To view or add a comment, sign in
-
-
⏳ Leetcode #1611: Minimum One Bit Operations to Make Integers Zero 🔍 Today I picked up a problem that looked chaotic at first: transforming any integer into zero using very restricted bit-flip rules. Every bit could only flip if the bits below it satisfied certain conditions, making the process feel unpredictable 🧩. But once I dug deeper, something interesting appeared. The pattern wasn’t random at all; it was secretly following Gray Code. That realization turned a confusing sequence of operations into a clean, structured transformation ✨. ✅ Key Insight: The number of operations directly aligns with converting a Gray-Code-like representation of n into its binary form. ✅ Time Complexity: O(log n) ✅ Space Complexity: O(1) These are the moments that make problem solving rewarding: when the “why is this so messy?” suddenly becomes “this is actually lowkey clean” 🧠💡. #DataStructures #LeetCode #CodingChallenge #ProblemSolving #Python #DSA #ComputerScience #learningEveyDay
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