💻 Strengthening My Algorithmic Skills with LeetCode (Java) Recently solved a few problems focusing on string manipulation and pattern-based logic, which helped me improve both problem decomposition and implementation clarity: 🔹 Zigzag Conversion Implemented a pattern-based traversal to simulate zigzag text arrangement across multiple rows. Approach: Row-by-row traversal Time Complexity: O(n) 🔹 Find the Index of the First Occurrence in a String (strStr) Developed a substring matching solution using a straightforward iterative comparison. Approach: Sliding window Time Complexity: O(n × m) 🔹 Reverse Words in a String Solved by splitting the input string, trimming spaces, and reconstructing it in reverse order. Approach: String split + reverse iteration Time Complexity: O(n) These problems helped strengthen my understanding of string operations, pattern logic, and efficient iteration techniques. #LeetCode #Java #DSA #ProblemSolving #Algorithms #Coding #SoftwareEngineering
Improved algorithmic skills with LeetCode Java problems
More Relevant Posts
-
💻 Enhancing Problem-Solving Skills with LeetCode (Java) Recently solved a couple of fundamental algorithmic problems that helped strengthen my understanding of two-pointer techniques, array manipulation, and writing efficient solutions. 🔹 Container With Most Water Implemented an optimised two-pointer approach to find the maximum water area between vertical lines. Instead of checking every pair (which would be O(n²)), the solution smartly moves the pointer at the shorter height inward to explore potentially larger areas. Approach: Two Pointers, Greedy Time Complexity: O(n) Space Complexity: O(1) 🔹 3Sum Solved the classic triplet-finding challenge by sorting the array and using two pointers to efficiently search for combinations that sum to zero. Also handled duplicates to avoid repeated triplets. Approach: Sorting + Two Pointers Time Complexity: O(n²) Space Complexity: O(1) (excluding output list) These problems helped sharpen my understanding of pointer movement, edge-case management, and designing clean, efficient solutions. #LeetCode #Java #Algorithms #DSA #Coding #ProblemSolving #SoftwareEngineering #LearningJourney
To view or add a comment, sign in
-
💻 Strengthening Problem-Solving Skills with LeetCode (Java) Recently explored a few interesting problems that focused on string manipulation, array traversal, and text formatting — each reinforcing clarity and precision in algorithmic thinking: 🔹 Text Justification Implemented a custom text alignment algorithm that evenly distributes spaces between words to fit a given line width. Approach: Greedy + StringBuilder Time Complexity: O(n) 🔹 Two Sum II – Input Array Is Sorted Solved using a two-pointer technique to efficiently find pairs that add up to a target value in a sorted array. Approach: Two Pointers Time Complexity: O(n) 🔹 Is Subsequence Checked whether one string is a subsequence of another using linear traversal and pointer comparison. Approach: Two Pointers Time Complexity: O(n) 🔹 Valid Palindrome Validated alphanumeric palindromes by filtering characters and comparing from both ends. Approach: String cleaning + two-pointer comparison Time Complexity: O(n) These problems helped sharpen my logic-building process and improved my confidence in designing efficient, readable solutions. #LeetCode #Java #ProblemSolving #DSA #Algorithms #Coding #SoftwareEngineering
To view or add a comment, sign in
-
💻 Day 11 of #100DaysOfLeetCode – Rotate Image Today’s challenge was “Rotate Image”, a classic matrix manipulation problem that tests both logic and spatial reasoning. 🔹 Problem Statement: Given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise) — all in place, without using extra memory for another matrix. 🔹 My Approach (in Java): I used a two-step in-place transformation technique: 1️⃣ Transpose the matrix — swap elements across the diagonal (matrix[i][j] ↔ matrix[j][i]). 2️⃣ Reverse each row — to achieve the 90° clockwise rotation. This approach ensures O(1) extra space and O(n²) time complexity, which is optimal for this problem. 🔹 Key Takeaways: ✅ Learned how matrix transformations can be broken down into simpler operations. ✅ Improved understanding of in-place algorithms and memory efficiency. ✅ Reinforced clean coding habits and edge case handling. Every rotation brings me one step closer to mastering problem-solving patterns! 💪 #100DaysOfLeetCode #CodingJourney #RotateImage #Java #DSA #ProblemSolving #LeetCode #CodingChallenge #LearningEveryday
To view or add a comment, sign in
-
-
📌 Day 2/100 – Remove Element (LeetCode 27) 🔹 Problem: Given an integer array nums and a value val, remove all instances of that value in-place and return the new length of the array. The order of elements can be changed. 🔹 Approach: Used the two-pointer technique to efficiently modify the array in-place. One pointer iterates through the array, while the other tracks the position to overwrite non-val elements. Returned the position of the second pointer as the new length. 🔹 Key Learning: Strengthened understanding of in-place array manipulation. Improved logic building for pointer movement and conditional overwriting. Learned how to minimize extra space usage while maintaining readability and clarity. Another small yet powerful step toward mastering array-based problems! 💻 🔥 #100DaysOfCode #LeetCode #Java #ProblemSolving #TwoPointers #DSA #CodingJourney
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
-
-
🔹 Day 39 – LeetCode Practice Problem: Perfect Number (LeetCode #507) 📌 Problem Statement: A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding itself. Return true if the given number is perfect, otherwise return false. ✅ My Approach (Java): Initialize sum = 0. Iterate from 1 to num / 2. For every divisor i such that num % i == 0, add it to sum. After the loop, if sum == num, it’s a perfect number. 📊 Complexity: Time Complexity: O(n/2) Space Complexity: O(1) ⚡ Submission Results: Accepted ✅ Runtime: 2108 ms Memory: 41.19 MB 💡 Reflection: This problem reinforced the importance of divisor-based iteration. While this brute-force solution works, optimizing divisor checks using square roots can greatly improve performance — a good next step for refinement! #LeetCode #ProblemSolving #Java #DSA #CodingPractice #Learning
To view or add a comment, sign in
-
-
🚀Day 29/100 - Problem of the day :- Minimum Number of Increments on Subarrays to Form a Target Array. 🎯 Goal: Solve the “Minimum Number of Increments on Subarrays to Form a Target Array” problem efficiently on LeetCode. 💡 Core Idea: The key observation is that we only need to add operations when the current element is greater than the previous one. So, the total operations = target[0] + sum(max(target[i] - target[i-1], 0)). This approach ensures we only count necessary increments, avoiding redundant steps. 🎯 Key Takeaway: By focusing on the difference between consecutive elements, we transform a complex problem into a simple linear pass — achieving both clarity and top performance. ✅ Passed all 129 test cases 🚀 Runtime beats 100% of Java submissions 💾 Space Complexity: O(1) — constant extra space used. ⏱ Time Complexity: O(n) — single pass through the array. #Java #DSA #ProblemSolving #Day29 #Leetcode #CodingJourney #100DaysChallenge
To view or add a comment, sign in
-
-
🚀Day 5️⃣9️⃣of #100DaysOfCode Solved LeetCode 3354 – Make Array Elements Equal to Zero 🧮 ⚡ Runtime: 1 ms (Beats 83.13%) 📊 Memory: 42.10 MB (Beats 69.28%) 🔍 Concept: This problem revolves around array traversal, directional logic, and state transitions. You start from an index where the element is 0 and move left or right while updating values and reversing direction — until all elements reach zero. 🧩 Approach Summary: Identify the initial index containing 0. Traverse left and right, updating values and counting valid selections. Keep it simple, linear, and effective. Some problems test patience as much as skill — but every solved logic strengthens the problem-solving mindset. #LeetCode #Java #ProblemSolving #100DaysOfCode #CodingJourney #SoftwareEngineer #Developer #AlgorithmDesign #Consistency #LearningEveryday
To view or add a comment, sign in
-
-
Winter may be coming ❄️, but the code still runs fast ⚔️ Cracked one of the toughest LeetCode Hard problems – Median of Two Sorted Arrays 🔥 Hit 100% runtime efficiency (1 ms) with clean and optimized binary search logic 🧠 This one tested everything — edge cases, math logic, and patience 😅 But as they say… “You win or you debug again.” 🐉 #LeetCode #DSA #CodingJourney #BinarySearch #Java #ProblemSolving #WinterIsComing #GameOfCodes
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 74 Count and Say Problem: Given an integer n, return the n-th term of the “Count and Say” sequence a fascinating pattern where each term describes the previous one. Example: Input: n = 4 Output: "1211" My Approach: Used recursion to generate the previous term. Applied run-length encoding logic counted consecutive digits and built the next term using a StringBuilder. Optimized for clean, readable iteration with O(N²) complexity (due to string building). Understanding recursive string construction deepens how we visualize “generation-based” sequences it’s not just about coding, it’s about seeing patterns grow. #100DaysOfCode #Java #LeetCode #ProblemSolving #Recursion #StringManipulation #CodingJourney #TechWithPurpose #takeUforward
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