🚀 Day 90 of My 100 Days LeetCode Challenge | Java Today’s challenge was a fascinating logic + mathematical insight problem. The task was to generate a binary string that does not exist in a given list of binary strings, where all strings have the same length. Instead of trying every possible combination, the solution becomes much simpler when you use the idea of diagonal flipping. By flipping the i-th bit of the i-th string, we guarantee that the newly created string differs from every string in the list at least in one position. This clever trick ensures the generated string is always unique. ✅ Problem Solved: Find Unique Binary String ✔️ All test cases passed (186/186) ⏱️ Runtime: 0 ms 🧠 Approach: Mathematical Insight (Diagonal Construction) 🧩 Key Learnings: ● Sometimes the smartest solutions come from mathematical reasoning rather than brute force. ● The diagonalization technique guarantees uniqueness. ● Understanding problem constraints can drastically simplify the approach. ● Logical insights can reduce exponential possibilities to linear solutions. ● Elegant algorithms often come from simple observations. This problem was a great reminder that a small logical trick can outperform complex algorithms. 🔥 Day 90 complete — sharpening my problem-solving intuition and algorithmic thinking. #LeetCode #100DaysOfCode #Java #Math #Algorithms #ProblemSolving #DSA #CodingJourney #Consistency
90 Days of LeetCode Challenge: Unique Binary String Solution in Java
More Relevant Posts
-
🚀 Day 58 / 100 – LeetCode Challenge ✅ Problem Solved: Binary Tree Postorder Traversal 📊 Difficulty: Easy 💻 Language: Java Today’s problem focused on understanding tree traversal, specifically Postorder Traversal (Left → Right → Root). 🔍 Key Learnings: Mastered recursive approach for tree traversal Understood how DFS (Depth First Search) works in binary trees Strengthened problem-solving with clean and efficient logic ⚡ Performance: Runtime: 0 ms (Beats 100%) 🔥 Memory: 42.96 MB 💡 Approach: Used a simple recursive helper function: Traverse left subtree Traverse right subtree Add root node value This problem may be easy, but it builds a strong foundation for advanced tree problems 💪 📈 Consistency is key — 58 days down, 42 more to go! #LeetCode #100DaysOfCode #Java #DataStructures #CodingJourney #BinaryTree #DSA #Learning #Consistency
To view or add a comment, sign in
-
-
Day 60 of #100DaysOfLeetCode 💻✅ Solved #389. Find the Difference problem in Java. Approach: • Initialized a variable to store the sum • Subtracted ASCII values of all characters in string s • Added ASCII values of all characters in string t • The remaining value represents the extra character • Converted the result back to character and returned it Performance: ✓ Runtime: 3 ms (Beats 38.82% submissions) ✓ Memory: 43.34 MB (Beats 30.69% submissions) Key Learning: ✓ Learned a clever use of ASCII values for problem solving ✓ Practiced using math-based approach instead of extra data structures ✓ Improved understanding of string manipulation techniques Learning one problem every single day 🚀 #Java #LeetCode #DSA #Strings #Math #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 99 of My 100 Days LeetCode Challenge | Java Today’s problem was all about randomization and linked list traversal — a nice break from heavy DP and matrices. The challenge was to design a system that returns a random node’s value from a singly linked list, ensuring that every node has an equal probability of being chosen. Since linked lists don’t allow direct indexing, the key idea was to first determine the size of the list, and then generate a random index to fetch the corresponding node. This approach ensures uniform randomness while keeping the implementation simple and efficient. ✅ Problem Solved: Linked List Random Node ✔️ All test cases passed (8/8) ⏱️ Runtime: 11 ms 🧠 Approach: Linked List Traversal + Randomization 🧩 Key Learnings: ● Randomization problems require ensuring uniform probability distribution. ● Linked lists limit direct access, so traversal becomes essential. ● Precomputing size can simplify random selection. ● Sometimes simple approaches are the most effective. ● Understanding data structure limitations helps design better solutions. This problem highlighted how probability + data structures can come together in elegant ways. 🔥 Day 99 complete — sharpening my understanding of randomization and linked list behavior. #LeetCode #100DaysOfCode #Java #LinkedList #Randomization #Algorithms #ProblemSolving #DSA #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🔥 𝗗𝗮𝘆 𝟵𝟰/𝟭𝟬𝟬 — 𝗟𝗲𝗲𝘁𝗖𝗼𝗱𝗲 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲 𝟭𝟱𝟯𝟵. 𝗞𝘁𝗵 𝗠𝗶𝘀𝘀𝗶𝗻𝗴 𝗣𝗼𝘀𝗶𝘁𝗶𝘃𝗲 𝗡𝘂𝗺𝗯𝗲𝗿 | 🟢 Easy | Java Marked as Easy — but the optimal solution is pure binary search brilliance. 🎯 🔍 𝗧𝗵𝗲 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 Given a sorted array, find the kth missing positive integer. Linear scan works — but can we do O(log n)? 💡 𝗧𝗵𝗲 𝗞𝗲𝘆 𝗜𝗻𝘀𝗶𝗴𝗵𝘁 At index i, the value arr[i] should be i+1 in a complete sequence. So missing numbers before arr[i] = arr[i] - 1 - i This lets us binary search on the count of missing numbers! ⚡ 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵 — 𝗕𝗶𝗻𝗮𝗿𝘆 𝗦𝗲𝗮𝗿𝗰𝗵 ✅ If arr[mid] - 1 - mid < k → not enough missing numbers yet, go right ✅ Else → too many missing, go left ✅ After the loop, left + k gives the exact answer 𝗪𝗵𝘆 𝗹𝗲𝗳𝘁 + 𝗸? After binary search, left is the index where the kth missing number falls beyond. left numbers exist in the array before that point, so the answer is left + k. No extra passes needed. ✨ 📊 𝗖𝗼𝗺𝗽𝗹𝗲𝘅𝗶𝘁𝘆 ⏱ Time: O(log n) — vs O(n) linear scan 📦 Space: O(1) This is a perfect example of binary searching on a derived condition, not just a value. A real upgrade from the naive approach. 🧠 📂 𝗙𝘂𝗹𝗹 𝘀𝗼𝗹𝘂𝘁𝗶𝗼𝗻 𝗼𝗻 𝗚𝗶𝘁𝗛𝘂𝗯: https://lnkd.in/gVYcjNS6 𝟲 𝗺𝗼𝗿𝗲 𝗱𝗮𝘆𝘀. 𝗧𝗵𝗲 𝗳𝗶𝗻𝗶𝘀𝗵 𝗹𝗶𝗻𝗲 𝗶𝘀 𝗿𝗶𝗴𝗵𝘁 𝘁𝗵𝗲𝗿𝗲! 🏁 #LeetCode #Day94of100 #100DaysOfCode #Java #DSA #BinarySearch #Arrays #CodingChallenge #Programming
To view or add a comment, sign in
-
🚀 Day 97 of My 100 Days LeetCode Challenge | Java Today’s problem was a solid exercise in matrix processing and prefix sum optimization. The goal was to count the number of submatrices whose sum is less than or equal to a given value (k). A brute-force approach would be too slow, so the key was to use 2D prefix sums to efficiently compute submatrix sums. By converting the matrix into a prefix sum matrix, we can calculate the sum of any submatrix in constant time, making the overall solution much more efficient. ✅ Problem Solved: Count Submatrices With Sum ≤ K ✔️ All test cases passed (859/859) ⏱️ Runtime: 7 ms 🧠 Approach: 2D Prefix Sum 🧩 Key Learnings: ● Prefix sums are powerful for optimizing repeated range sum queries. ● 2D prefix sums extend the same idea from arrays to matrices. ● Preprocessing can drastically reduce computation time. ● Avoiding brute force is key in large input problems. ● Matrix problems often become easier with the right transformation. This problem reinforced how preprocessing techniques like prefix sums can turn complex problems into efficient solutions. 🔥 Day 97 complete — sharpening matrix optimization and prefix sum skills. #LeetCode #100DaysOfCode #Java #PrefixSum #Matrix #Algorithms #ProblemSolving #DSA #CodingJourney #Consistency
To view or add a comment, sign in
-
-
\🚀 Day 15 of My LeetCode Journey 🧩 Problem Solved: 1980. Find Unique Binary String 💻 Language: Java Today I worked on a problem where we are given n unique binary strings, each of length n, and we need to find another binary string of length n that does not exist in the list. 🔍 Key Insight: Instead of checking all possible binary combinations, we can build a new string by flipping the i-th bit of the i-th string. This guarantees the new string will differ from every string in the array at least at one position. ⚡️ Concept Used: Diagonalization technique 📈 Time Complexity: O(n) 📦 Space Complexity: O(n) 💡 This problem reminded me that sometimes the smartest solutions come from simple observations rather than brute force approaches. Consistency is key — solving problems daily to strengthen my Java and problem-solving skills. #LeetCode #Java #CodingJourney #ProblemSolving #100DaysOfCode #DataStructures #LearningInPublic
To view or add a comment, sign in
-
-
Every problem teaches something new — today it was LeetCode 50: Pow(x, n) At first, it looked simple: just calculate power. But the real challenge was optimizing it and handling edge cases like negative powers and Integer.MIN_VALUE overflow. Learned how Binary Exponentiation can turn an O(n) solution into O(log n) — that’s the beauty of algorithms! Moments like these remind me that problem-solving is not just about writing code, but thinking deeper. #LeetCodeJourney #DSA #KeepLearning #Java #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 18 of my Java DSA Journey Today I solved " Find the Index of the First Occurence in a String "— LeetCode Problem #28. 🔹 Problem Given two strings haystack and needle, return the index of the first occurrence of "needle" in "haystack". If the substring does not exist, return -1. 🔹 Approach Used: Substring Search (Brute Force) Idea • Check every possible starting index in the main string. • Compare characters of needle with haystack one by one. • If all characters match, return that starting index. 📊 Complexity • Time Complexity: O(n × m) • Space Complexity: O(1) 💡 Key Learning Understanding the brute-force approach helps build the foundation for more advanced string matching algorithms like KMP. 🔗 GitHub Solution: https://lnkd.in/gW8atfqw Consistent daily practice is helping me improve my problem-solving and algorithmic thinking step by step. #Java #DSA #LeetCode #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 95 of My 100 Days LeetCode Challenge | Java Today’s challenge was a grid traversal + simulation problem that required careful observation of patterns. The goal was to find the three largest rhombus border sums in a grid. Unlike regular submatrix problems, this one only considers the border elements of rhombus shapes, which makes the calculation a bit more tricky. The approach involved exploring each cell as a potential rhombus center, expanding possible rhombus sizes, and calculating the sum of the boundary elements while ensuring the rhombus stays within grid limits. A TreeSet helped efficiently keep track of the top three unique sums. ✅ Problem Solved: Get Biggest Three Rhombus Sums in a Grid ✔️ All test cases passed (117/117) ⏱️ Runtime: 217 ms 🧠 Approach: Grid Traversal + Simulation + TreeSet 🧩 Key Learnings: ● Grid problems often require careful boundary management. ● Visualizing shapes (like rhombuses) helps simplify implementation. ● TreeSet is useful for maintaining sorted unique values efficiently. ● Simulation-based solutions demand attention to detail. ● Not every grid problem is about rectangles — shapes matter too. This problem was a good reminder that geometric patterns in grids can lead to interesting algorithmic challenges. 🔥 Day 95 complete — improving my grid traversal and pattern-handling skills. #LeetCode #100DaysOfCode #Java #GridProblems #Algorithms #ProblemSolving #DSA #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 57 of #100DaysOfLeetCode 💻✅ Solved #506. Relative Ranks problem in Java. Approach: • Iterated through each player's score • Compared it with all other scores to determine its rank • Increased rank whenever a higher score was found • Assigned medals for top 3 ranks: Gold, Silver, Bronze • Converted remaining ranks to string and stored in result array Performance: ✓ Runtime: 124 ms (Beats 5.06% submissions) ✓ Memory: 46.76 MB (Beats 99.84% submissions) Key Learning: ✓ Understood ranking logic using comparison ✓ Practiced nested loop approach for problem solving ✓ Learned the importance of optimizing time complexity Learning one problem every single day 🚀 #Java #LeetCode #DSA #Arrays #Sorting #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