LeetCode 3289 (The Two Sneaky Numbers of Digitville) Achieved a 0 ms runtime (Beats 100.00%) using a precise single-pass discovery approach! The goal is to find two numbers that appear twice in a list where everyone else appears once. I iterated through the numbers exactly once, tracking "seen" values.The moment a number is encountered again, it’s identified as "sneaky" and added to the results.By using simple, direct list interactions in Python, the solution hits the performance floor with no wasted cycles. #LeetCode #Python #Algorithms #Optimization #CleanCode #SoftwareEngineering #DSA
LeetCode 3289: Two Sneaky Numbers in Digitville
More Relevant Posts
-
🚀 Day 39 of #100DaysOfCode Solved Add Binary today! Problem: Given two binary strings, return their sum as a binary string. At first glance, it looks simple — but the key is handling: ✔ Carry correctly ✔ Different string lengths ✔ Edge case when carry remains at the end Instead of converting to integers, I implemented the manual binary addition approach (right to left with carry). This ensures the solution works efficiently even for very large inputs. 🧠 Key Learning: Sometimes the best solution is to simulate the real-world process (just like how we do pen-and-paper addition). ⏱ Time Complexity: O(n) 📦 Space Complexity: O(n) Consistency > Motivation 💪 On to Day 40 🔥 #Day39 #LeetCode #Binary #ProblemSolving #CodingJourney #Python #DSA
To view or add a comment, sign in
-
-
Day 59 of 365 Days of code Couldn't solve problems properly in an optimized way, never mind, i still managed to solve it using a slow and a fast pointer. Qn 1) find the duplicate number The array will contain a duplicate element, we must find the element which has duplicate, without using an hashset. sounds scary :(. Approach: fast and slow pointers Gd nit #365daysOfCode #NeetCode #leetcode #DSA #python #LeetCode #ProblemSolving #Algorithms #365dayschallenge
To view or add a comment, sign in
-
-
✅ Day 9 of #DSAPrep > Problem: Square Root of a Number > Platform: LeetCode > Concept: Mathematical Computation Computed the square root of a number using exponentiation, > Key Idea: - num ** 0.5 gives the square root - int() returns the floor value > Example: 36 → 6 > Time Complexity: O(1) > Space Complexity: O(1) Sometimes the simplest approach is the cleanest one ✅ Consistency continues 🚀 #DSAPrep #Python #Algorithms #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 4/60 ✅ Solved Form the Largest Number. The key idea was customizing the sorting logic. Instead of normal numerical sorting, I compared numbers as strings by checking which combination — a+b or b+a — forms a larger value. This ensures the final concatenation produces the maximum possible number. Time Complexity: O(n log n) A good reminder that sometimes the problem isn’t about complex logic — just about choosing the right comparison strategy. #60DayChallenge #DSA #ProblemSolving #Python
To view or add a comment, sign in
-
-
Day 96 – LeetCode Journey Another step forward in consistency and problem-solving discipline. Today’s problem: Find the Distance Value Between Two Arrays Key learning: Understanding “there is NOT ANY element…” type conditions. Using nested loops with proper break logic. Leveraging Python’s for-else construct effectively. Strengthening brute-force reasoning before optimization. Result: ✅ 103 / 103 test cases passed ⚡ Runtime: 47 ms 💾 Memory efficiency: Strong performance Every day isn’t about solving the hardest problem — it’s about sharpening logic and avoiding small mistakes. Consistency > Intensity. #Day96 #LeetCode #ProblemSolving #Python #DSA #Consistency #100DaysOfCode
To view or add a comment, sign in
-
-
feb-22-26 LeetCode 762 – Prime Number of Set Bits in Binary Representation Solved today’s problem! ✅ The task is to count numbers in a given range [left, right] whose number of set bits (1s in binary form) is a prime number. ⚡ Complexity: Time: O(n log n) Space: O(1) A simple yet powerful problem combining binary operations and number theory 🔥 #LeetCode #DailyCoding #BitManipulation #Python #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🔥 Day 96 — #100DaysOfLeetCode ✅ Problem: Binary Number with Alternating Bits (Easy) Today’s challenge was to check whether a given integer’s binary representation has alternating bits — meaning no two adjacent bits are the same. 🧠 Approach: Convert number to binary. Check if it contains "11" or "00". If yes → not alternating. Otherwise → valid alternating pattern. ⚡ Example n = 5 → binary = 101 → ✔ alternating ⏱ Complexity Time: O(k) Space: O(1) (k = number of bits) #LeetCode #DSA #CodingChallenge #Python #ProblemSolving
To view or add a comment, sign in
-
-
LeetCode #226 – Invert Binary Tree | Python Implementation I implemented a recursive DFS approach that swaps left and right children at every node. Core Insight: Tree inversion is distributive — inverting a tree equals swapping its root's children and inverting each subtree independently. Recursion handles this naturally in O(n) time. Time: O(n) | Space: O(h) where h = tree height (recursion stack) #LeetCode #DataStructures #Python #BinaryTree #Recursion #DFS #CodingInterview #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 51 of #180DaysOfCode Today I solved LeetCode 28 – Find the Index of the First Occurrence in a String. This problem focuses on string searching, where the goal is to find the starting index of the first occurrence of a substring within a given string. 🔹 Problem: LeetCode 28 – Find the Index of the First Occurrence in a String https://lnkd.in/dTrXCCPC 📂 GitHub Repo: https://lnkd.in/dRjhS-zs #Python #DSA #LearnInPublic #CodingChallenge #LeetCode #DataStructures #Algorithms #PythonDSA #DailyCoding #Consistency #TechJourney #Upskill #CodeOfTheDay #Day51 🚀
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