🚀 Day 68 of #100DaysOfChallenge Today's problem: 3461. Check If Digits Are Equal in String After Operations I (LeetCode - Easy) This problem was a fun blend of pattern observation and modular arithmetic — a great reminder that even simple-looking questions can strengthen your logical flow and coding discipline on LeetCode. 🧩 Problem Overview: We’re given a string of digits, and in each step, we repeatedly calculate the sum of every pair of consecutive digits modulo 10, until only two digits remain. Finally, we check whether those two digits are equal. 💡 My Approach: Used a straightforward simulation approach — repeatedly computing new strings of digits using modular arithmetic until only two digits were left. It’s simple, direct, and performs efficiently for short strings. ⚙️ Language: Java ⚡ Runtime: 8 ms (Beats 72.03%) 💾 Memory: 44.67 MB (Beats 69.77%) ✅ Result: Accepted — 706 / 706 test cases passed Every daily problem adds another layer of precision and confidence. Consistency isn’t just about coding every day — it’s about learning something new with every attempt. 🌱 On to the next challenge 💪 #100DaysOfCode #LeetCode #ProblemSolving #Java #CodingChallenge #Programming #DeveloperJourney #LearningEveryday #TechMindset #Consistency
Solved LeetCode problem 3461 with Java, beating 72% in runtime.
More Relevant Posts
-
📌 Day 155 of Coding - Next Greater Numerically Balanced Number (LeetCode - Medium) 🎯 Goal: Find the smallest integer greater than n such that the count of each digit d in the number is exactly d (for digits 1-7). 💡Approach & Debugging: Used backtracking to generate all “beautiful” numbers following the digit count rule. A helper function generate() recursively built numbers by trying digits 1-7, ensuring that no digit appeared more times than its own value. Checked each generated number using isBeautiful(). After generation, sorted the list and returned the first number greater than n. ✔️ Time Complexity: Exponential (backtracking-based generation, but limited by small constraints). ✔️ Space Complexity: O(1) auxiliary + O(M) list for generated numbers. 🧠 Key Takeaways: Precomputation and pruning (like limiting to 1224444) help keep recursion efficient. Problems mixing digit frequency logic and recursion sharpen number theory intuition. #Day155 #LeetCode #Backtracking #Recursion #Java #ProblemSolving #DSA #CodingChallenge #Algorithms #100DaysOfCode #InterviewPrep #SoftwareEngineering #DataStructures #CodeNewbie #ProgrammersLife
To view or add a comment, sign in
-
-
🚀 Day 73 of #100DaysOfCode Today I solved LeetCode 3346 – Maximum Frequency of an Element After Performing Operations I 🧩 This problem was all about logical range manipulation — figuring out how many elements could be converted into the same number when each element can be modified by ±k, but with a limited number of allowed operations. At first, it felt similar to the “most frequent element” sliding window problem, but the twist here was controlling how many elements can be changed, not just the total cost. After a few failed attempts (and a battle with edge cases 😅), I finally implemented a correct solution using the difference array + prefix sum approach. 💡 Key Takeaways: Think in terms of ranges, not just differences. Prefix-sum (difference map) logic is incredibly powerful for interval counting. Always recheck constraints — “number of operations” vs “total cost” makes a huge difference! Here’s a snippet from my final Java solution: int achievable = Math.min(running, same + numOperations); ans = Math.max(ans, achievable); It’s small details like these that make problem-solving such a rewarding process 💪 #Java #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #DSA #LearningEveryday
To view or add a comment, sign in
-
-
🔹 Day 40 – LeetCode Practice Problem: Find Greatest Common Divisor of Array (LeetCode #1979) 📌 Problem Statement: Given an integer array nums, find the greatest common divisor (GCD) of the smallest and largest numbers in the array. ✅ My Approach (Java): 1. Find the minimum and maximum elements in the array. 2. Starting from the smaller number and going downwards, check for the highest integer that divides both min and max. 3. Return that integer as the GCD. 📊 Complexity: Time Complexity: O(n + min(a, b)) Space Complexity: O(1) ⚡ Submission Results: Accepted ✅ Runtime: 0 ms (Beats 100%) 🚀 Memory: 43.41 MB (Beats 41.55%) 💡 Reflection: This problem shows how basic math logic and loop optimization can lead to extremely efficient solutions. A simple and powerful way to practice number theory in coding! #LeetCode #ProblemSolving #Java #DSA #CodingPractice #Learning
To view or add a comment, sign in
-
-
🚀 Day 412 of #500DaysOfCode 🔹 LeetCode 474: Ones and Zeroes Difficulty: Medium | Topic: Dynamic Programming Today’s problem was all about balancing limits and maximizing choices — a classic 0/1 Knapsack twist! 🎒 🧩 Problem Summary: Given a list of binary strings and two integers m and n, find the largest subset of strings such that the total number of 0s ≤ m and the total number of 1s ≤ n. Example: Input: strs = ["10","0001","111001","1","0"], m = 5, n = 3 Output: 4 Explanation: Subset = {"10","0001","1","0"} ⚙️ Key Idea: Think of it like a two-dimensional knapsack problem: Each string "costs" a certain number of 0s and 1s. You have two limits — m zeros and n ones. Goal → pick the maximum number of strings without exceeding limits. We use a 2D DP table where: dp[i][j] = max number of strings we can form with i zeros and j ones. Update rule: 💡 Learning: This problem beautifully shows how Dynamic Programming can handle problems with multiple constraints. Just like in life — when you have limited time and energy, plan your choices smartly to maximize growth 🔥 💻 #DynamicProgramming #LeetCode #CodingChallenge #Java #ProblemSolving #CodeNewbie #100DaysOfCode #500DaysOfCode #LearningEveryday
To view or add a comment, sign in
-
-
🚀 Day-73 of #100DaysOfCodeChallenge 💡 LeetCode Problem: 3354. Make Array Elements Equal to Zero (Easy) 🧠 Concepts Practiced: Simulation, Array Manipulation, Direction Reversal Logic Today’s problem was all about simulating a dynamic process — starting from a zero element in an array, moving in a chosen direction, and adjusting movement logic as the array updates. It’s a great exercise in understanding flow control and direction-based simulation, where small logical errors can change the entire outcome. Patience and precision made all the difference here. 🔹 Approach: Simulated each possible starting point and direction, tracking movements and reversals until all elements became zero. Focus was on correctness and clear logic rather than over-optimization. ⚙️ Language: Java ⚡ Runtime: 100 ms (Beats 23.49%) 💾 Memory: 43.44 MB (Beats 13.25%) ✅ Result: 584 / 584 test cases passed — Accepted 🎯 Each solved problem reminds me how logic, structure, and consistency build stronger foundations for solving complex challenges ahead 💪 #100DaysOfCode #LeetCode #Java #CodingChallenge #ProblemSolving #Programming #DeveloperJourney #TechMindset #LearningEveryday #Consistency #Simulation
To view or add a comment, sign in
-
-
📌 Day 4/100 - Minimum Size Subarray Sum (LeetCode 209) 🔹 Problem: Given an array of positive integers and a target value, find the minimal length of a contiguous subarray whose sum is greater than or equal to the target. If there’s no such subarray, return 0. 🔹 Approach: Used the Sliding Window technique for an optimized solution: Initialize two pointers (low, high) and a running sum. Expand the window by moving high until the sum ≥ target. Once valid, shrink the window from the left to find the smallest subarray. Keep updating the minimum length throughout. This reduced the time complexity from O(n²) (brute force) to O(n). 🔹 Key Learning: Sliding Window is ideal for problems with contiguous subarrays. Optimization often comes from adjusting the window efficiently. Each problem strengthens logical flow and pattern recognition. Another step forward in mastering DSA and problem-solving consistency! ⚡ #100DaysOfCode #LeetCode #Java #ProblemSolving #DSA #CodingChallenge #SlidingWindow
To view or add a comment, sign in
-
-
💡 LeetCode 1929 – Concatenation of Array 💡 Today, I solved LeetCode Problem #1929: Concatenation of Array, a simple yet satisfying problem that tests your understanding of array manipulation and indexing in Java. ⚙️📊 🧩 Problem Overview: You’re given an integer array nums. Your task is to create a new array ans such that ans = nums + nums (i.e., concatenate the array with itself). 👉 Example: Input → nums = [1,2,1] Output → [1,2,1,1,2,1] 💡 Approach: 1️⃣ Find the length n of the given array. 2️⃣ Create a new array of size 2 * n. 3️⃣ Loop through nums once — place each element both at index i and index n + i. 4️⃣ Return the resulting array. ⚙️ Complexity Analysis: ✅ Time Complexity: O(n) — Single traversal of the array. ✅ Space Complexity: O(n) — For the concatenated array. ✨ Key Takeaways: Practiced index manipulation and array construction. Reinforced the importance of efficient iteration. A great warm-up problem that strengthens logical thinking and array fundamentals. 🌱 Reflection: Even the simplest problems build the foundation for solving more complex ones. Every bit of consistent practice helps in mastering problem-solving and clean coding habits. 🚀 #LeetCode #1929 #Java #ArrayManipulation #DSA #CodingJourney #CleanCode #ProblemSolving #AlgorithmicThinking #ConsistencyIsKey
To view or add a comment, sign in
-
-
💡 LeetCode 3467 – Transform Array 💡 Today, I solved LeetCode Problem #3467: Transform Array, which focuses on array manipulation and the use of conditional logic in Java — a neat problem that strengthens core programming fundamentals. ⚙️ 🧩 Problem Overview: You’re given an integer array nums. Your task is to: Replace even numbers with 0 Replace odd numbers with 1 Then, sort the transformed array in ascending order. 👉 Example: Input → nums = [4, 7, 2, 9] Output → [0, 0, 1, 1] 💡 Approach: 1️⃣ Iterate through the array. 2️⃣ Use a ternary operator to transform each element (even → 0, odd → 1). 3️⃣ Sort the array to arrange all zeros before ones. ⚙️ Complexity Analysis: ✅ Time Complexity: O(n log n) — due to sorting. ✅ Space Complexity: O(1) — in-place transformation. ✨ Key Takeaways: Practiced logical thinking and ternary operations in Java. Strengthened understanding of array transformations and sorting. Reinforced the value of writing clean, concise, and efficient code. 🌱 Reflection: Even simple transformation problems like this one sharpen the habit of thinking algorithmically. Consistency in small challenges leads to big growth in problem-solving skills. 🚀 #LeetCode #3467 #Java #ArrayManipulation #LogicBuilding #ProblemSolving #CodingJourney #DSA #CleanCode #ConsistencyIsKey
To view or add a comment, sign in
-
-
📌 Day 161 of Coding - Minimum Number of Increments on Subarrays to Form a Target Array (LeetCode - Hard) 🎯 Goal: Find the minimum number of operations required to form a target array starting from an array of zeros, where each operation increments all elements of a chosen subarray by 1. 💡Approach & Debugging: Used a difference-based greedy approach to count only the necessary increments. Steps: Initialize sum with the first element, representing the increments needed for the first number. Traverse the array: Whenever target[i] > target[i - 1], it means additional increments are needed. Add the difference (target[i] - target[i - 1]) to sum. The total sum gives the minimum number of operations required. ✔️ Time Complexity: O(N) - single pass through the array. ✔️ Space Complexity: O(1) - constant extra space. 🧠Key Takeaways: A classic prefix difference trick, focus on the increase, not the absolute value. Greedy approaches often emerge naturally in array transformation problems. #Day161 #LeetCode #GreedyAlgorithm #ArrayProblems #Java #ProblemSolving #DSA #Algorithms #CodingChallenge #InterviewPrep #100DaysOfCode #SoftwareEngineering #CodeNewbie #ProgrammersLife
To view or add a comment, sign in
-
-
🚀 Day 47 of My LeetCode Journey 🚀 Problem: Sum of Square Numbers Topic: Math / Two Pointers 🧠 Approach: To check if a number c can be expressed as the sum of squares of two integers (a² + b² = c), we use the two-pointer technique: Start a = 0 and b = √c Calculate sum = a² + b² If sum == c → ✅ return true If sum < c → increase a If sum > c → decrease b Repeat until a <= b. ⏱️ Complexity: Time: O(√c) Space: O(1) This problem beautifully combines mathematical logic with an efficient two-pointer approach — clean and elegant! 💡 #100DaysOfCode #LeetCode #Java #CodingChallenge #ProblemSolving #DSA
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