🚀 Day 44 of #100DaysOfCode Solved LeetCode Problem #961 – N-Repeated Element in Size 2N Array This problem was about identifying the element that repeats N times in an array of size 2N. The key insight is that the repeated element must appear very close to itself, allowing an efficient linear scan without extra space. Key Learnings: -> Used observation-based logic instead of extra data structures -> Checked only nearby indices to detect repetition early -> Achieved optimal O(n) time and O(1) space -> Reinforced pattern recognition in array problems Language Used: Java -> Runtime: 0 ms (Beats 100.00%) -> Memory: 47.85 MB Small observations can lead to optimal solutions 🚀 #LeetCode #Java #Arrays #ProblemSolving #100DaysOfCode #DSA
N-Repeated Element in Size 2N Array Solution in Java
More Relevant Posts
-
🚀 Day 71 of #100DaysOfCode Solved LeetCode Problem #2976 – Minimum Cost to Convert String I ✅ This problem revolved around graph algorithms and all-pairs shortest paths, where each character transformation had an associated cost. The key was efficiently finding the minimum cost to convert one string into another using allowed transformations. Key Learnings: -> Modeling character transformations as a weighted directed graph -> Applying Floyd–Warshall to precompute minimum conversion costs -> Handling unreachable transformations safely -> Aggregating per-character costs to compute the final answer Language Used: Java -> Runtime: 91 ms (Beats 13.62%) -> Memory: 48.16 MB (Beats 30.82%) Consistent progress, one problem at a time 🚀 On to the next challenge 💪 #LeetCode #Graphs #FloydWarshall #Java #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 49 of #100DaysOfCode Solved LeetCode Problem #1339 – Maximum Product of Splitted Binary Tree 🌳 This problem focused on splitting a binary tree into two subtrees such that the product of their sums is maximized. It required a two-pass DFS strategy first to compute the total sum, and second to evaluate every possible split efficiently. Key Learnings: -> Used DFS to calculate subtree sums -> Explored every edge as a potential split point -> Tracked the maximum product using global state -> Applied modulo arithmetic to handle large results Language Used: Java -> Runtime: 7 ms (Beats 47.86%) -> Memory: 60.07 MB Deepening tree recursion skills and optimization thinking, one problem at a time 🚀🌲 #LeetCode #BinaryTree #DFS #Java #ProblemSolving #DSA #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 69 of #100DaysOfCode Solved LeetCode Problem #3650 – Minimum Cost Path with Edge Reversals ✅ This problem was a great application of graph algorithms, where the goal was to minimize cost by smartly handling edge directions and reversals. Modeling the problem correctly made all the difference. Key Learnings: -> Converting edge reversals into weighted edges -> Using graph representation effectively -> Applying Dijkstra’s algorithm for shortest path -> Thinking beyond direct edges to optimize cost Language Used: Java -> Runtime: 75 ms (Beats 85.02%) -> Memory: 275.60 MB (Beats 39.27%) Consistency > Motivation 🚀 Onwards to Day 68 💪 #LeetCode #GraphAlgorithms #Dijkstra #Java #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 72 of #100DaysOfCode Solved LeetCode Problem #2977 – Minimum Cost to Convert String II ✅ This was a more advanced follow-up that required handling string-level transformations efficiently. The challenge was to minimize the total cost by choosing optimal substring conversions rather than single-character changes. Key Learnings: -> Using a Trie to store and index valid string transformations -> Modeling transformation costs with dynamic programming -> Combining Trie traversal + DP for efficient substring matching -> Carefully managing state transitions to avoid unnecessary recomputation Language Used: Java -> Runtime: 209 ms (Beats 34.88%) -> Memory: 48.68 MB (Beats 18.60%) Step by step, leveling up problem-solving depth and string algorithm intuition 🚀 #LeetCode #DynamicProgramming #Trie #Java #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 68 of #100DaysOfCode Solved LeetCode Problem #1200 – Minimum Absolute Difference ✅ A clean and elegant problem where sorting does most of the heavy lifting. By comparing adjacent elements after sorting, we can efficiently find all pairs with the minimum absolute difference. Key Learnings: -> Sorting simplifies difference-based problems -> Adjacent comparison is enough after sorting -> Clear logic beats complex data structures -> Collecting results while tracking the minimum difference Language Used: Java -> Runtime: 20 ms (Beats 97.70%) -> Memory: 64.05 MB (Beats 32.62%) Step by step, day by day 🚀 On to the next problem 💪 #LeetCode #Java #ProblemSolving #Algorithms #Sorting #Arrays #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 67 of #100DaysOfCode Solved LeetCode Problem #1984 – Minimum Difference Between Highest and Lowest of K Scores ✅ This problem focused on minimizing the score gap by smartly selecting k elements after sorting the array. A perfect example of how sorting + sliding window logic can turn a problem simple and efficient. Key Learnings: -> Sorting simplifies comparisons -> Sliding window to evaluate consecutive groups of size k -> Avoid brute force by leveraging order -> Small observations lead to clean solutions Language Used: Java -> Runtime: 8 ms (Beats 89.22%) -> Memory: 47.09 MB (Beats 25.34%) Consistency > Intensity 💪 On to the next challenge 🚀 #LeetCode #Java #ProblemSolving #Algorithms #Sorting #SlidingWindow #100DaysOfCode
To view or add a comment, sign in
-
-
Day28 - LeetCode Journey Solved LeetCode 383: Ransom Note in Java ✅ This problem was a great example of how frequency counting can simplify string-based logic. The task was to check whether a ransom note can be constructed using characters from a magazine, with each character usable only once. Using a fixed-size frequency array made the solution clean and efficient. First counting all characters in the magazine and then consuming them while checking the ransom note felt very intuitive. The moment any required character ran out, we could immediately return false. Simple logic, strong impact. What stood out here was how important it is to choose the right data structure. A small optimization like using an array instead of a map makes the solution faster and more memory-efficient. Key takeaways: • Effective use of frequency arrays • Strong practice of string traversal • Early termination for better performance • Writing optimized and readable code ✅ Accepted successfully ✅ 1 ms runtime with top performance Problems like these quietly sharpen your fundamentals. Staying consistent, one problem at a time 💪 #LeetCode #Java #DSA #Strings #ProblemSolving #Algorithms #CodingJourney #InterviewPreparation #DailyPractice #Consistency
To view or add a comment, sign in
-
-
🔹 Day 96 – LeetCode Practice 📌 Problem: First Missing Positive (LeetCode #41) 📊 Difficulty: Hard 🧠 Problem Overview: Given an unsorted integer array, the task is to find the smallest positive integer that is missing from the array. The challenge lies in solving it efficiently with strict constraints on time and space. ✅ Approach Used: Stored all values from the array for quick lookup. Iterated from the smallest possible positive integer to identify the first missing value. Returned the earliest number that was not present. 📈 Submission Results: Status: Accepted ✅ Runtime: 14 ms Memory Usage: 93.44 MB 💡 Reflection: This problem highlights the importance of understanding constraints clearly. While multiple approaches exist, optimizing time and space is the key learning takeaway from this question. #LeetCode #DSA #ProblemSolving #Arrays #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 45 of #100DaysOfCode Solved LeetCode Problem #1411 – Number of Ways to Paint N × 3 Grid 🎨 This problem focused on counting valid colorings of an N × 3 grid such that no two adjacent cells (horizontally or vertically) have the same color. The challenge was to recognize repeating patterns and optimize the solution using dynamic programming. Key Learnings: -> Broke the problem into two repeating pattern states (2-color & 3-color combinations) -> Derived recurrence relations to transition between rows -> Used constant space DP for optimal performance -> Reinforced how mathematical observation simplifies complex DP problems Language Used: Java -> Runtime: 2 ms (Beats 99.49%) -> Memory: 42.06 MB Dynamic programming becomes powerful when patterns are clearly identified 🚀 #LeetCode #DynamicProgramming #Java #ProblemSolving #100DaysOfCode #DSA
To view or add a comment, sign in
-
-
Day 47/50 of #50DaysOfDSA 🚀 Today’s focus was on string manipulation and stack-based logic with LeetCode 1614 — Maximum Nesting Depth of the Parentheses. The Problem: Given a valid parentheses string, the goal is to find the maximum nesting depth. My Approach: Instead of using an actual stack data structure, I used a simple counter to track the current depth: Increment the counter when encountering ( Decrement when encountering ) Track the maximum value the counter reaches during the iteration. The Result: ✅ Runtime: 0 ms (Beats 100.00% of Java submissions!) ✅ Complexity: O(n) time and O(1) space. It’s satisfying to see how a simple linear scan can be so performant. Almost at the finish line! 🏁 #DSA #CodingChallenge #Java #LeetCode #ProblemSolving #SoftwareEngineering #Day47
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
Solid work O(n) time & O(1) space — well done