🚀 Mastering Java Through LeetCode 🧠 Day 2 I’m continuing my journey of solving problems from the LeetCode 75 list to strengthen my Data Structures and Algorithms (DSA) skills using Java. Consistency in problem-solving is helping me improve logical thinking and prepare for real-world software engineering interviews. 📌 LeetCode problem solved today: Q. 1071 – Greatest Common Divisor of Strings 📝 Problem Summary: For two strings s and t, we say t divides s if s is formed by repeating t multiple times. 👉 The goal is to find the largest string x that divides both str1 and str2. 💡 Key Insight: ✔️ If (str1 + str2).equals(str2 + str1) → a common pattern exists ✔️ Then the answer is based on GCD of lengths 💻 Key Java concepts practiced: ✔️ String concatenation & comparison ✔️ Pattern recognition in strings ✔️ Recursion (GCD using Euclidean algorithm) ✔️ Substring operations ✔️ Combining math with programming logic Takeaway: This problem shows how combining Mathematical concepts (GCD) with String manipulation can lead to efficient solutions. #Java #DSA #LeetCode #ProblemSolving #CodingJourney #JavaDeveloper #TechSkills #LearningInPublic #CodingPractice #SoftwareEngineering #Developers #CodingLife
Mastering Java with LeetCode: GCD of Strings
More Relevant Posts
-
🚀 Week 8 – Java + DSA Journey Update This week was all about strengthening my problem-solving skills and diving deeper into Data Structures using Java. 💻 🔹 What I focused on: Arrays & Advanced Array Problems Two Pointer Technique Sliding Window Concepts Solved multiple problems on LeetCode 🔹 Key Learnings: Learned how to optimize brute force solutions into efficient ones (O(n)) Understood real use of two pointers in problems like pair sum & sorting-based questions Sliding window made problems like longest substring much more efficient 🔹 Challenges faced: Some problems looked easy but required deep thinking to optimize. Debugging logic took time, but consistency helped 💪 🔹 Progress: Improved coding speed ⏱️ Better understanding of patterns instead of just memorizing solutions 📌 Goal for next week: Start Linked List Practice medium-level problems consistently Consistency is the only key 🔑 #Java #DSA #LeetCode #CodingJourney #SoftwareEngineering #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Mastering Java Through LeetCode 🧠 Day 7 Continuing my journey of solving problems from the LeetCode 75 list to strengthen my Data Structures and Algorithms (DSA) skills using Java. Consistent practice is helping me improve problem-solving ability and preparing for real-world software development and placements. 📌 LeetCode Problem Solved Today: Q. 238 – Product of Array Except Self Given an integer array nums, we need to return an array where each element is the product of all elements of the array except itself. Example: Input: nums = [1,2,3,4] Output: [24,12,8,6] This problem was interesting because: We must solve it in O(n) time complexity We cannot use the division operator It requires understanding of prefix and suffix product technique 💡 Key Learning from Today Optimizing brute force solutions Understanding prefix and suffix multiplication Writing efficient algorithms with O(n) complexity Strengthening array manipulation skills in Java 🧑💻 Approach Used Instead of calculating the product repeatedly, I used: Left product pass Right product pass This helped reduce the time complexity from O(n²) → O(n). 📈 Every day I’m getting better at: Problem solving Writing optimized code Preparing for technical interviews #LeetCode #Java #DSA #ProblemSolving #CodingJourney #LearningInPublic #SoftwareDevelopment
To view or add a comment, sign in
-
-
🚀 Mastering Java Through LeetCode 🧠 Day 6 Continuing my journey of solving problems from the LeetCode 75 list to strengthen my Data Structures and Algorithms (DSA) skills using Java. Daily coding practice is helping me improve logical thinking, problem-solving ability, and writing cleaner code for real-world applications. 📌 LeetCode Problem Solved Today: Q. 151 – Reverse Words in a String – from LeetCode 🔍 What I Learned: Handling strings with leading, trailing, and multiple spaces Using trim() and split() with regex (\\s+) Reversing words efficiently using StringBuilder Improving string manipulation with O(n) time complexity 💡 Problem Summary: We are given a string s that may contain extra spaces between words or at the beginning/end. The goal is to reverse the order of the words while ensuring: Only one space between words No leading or trailing spaces in the final result. Example: Input: "the sky is blue" Output: "blue is sky the" Another Example: Input: " hello world " Output: "world hello" In this problem, the key challenge is cleaning the spaces first and then reversing the order of the words correctly. ✅ The approach I used: Remove extra spaces using trim(). Split the string using split("\\s+"). Traverse the words array in reverse order. Build the final string using StringBuilder. This problem helped me better understand string processing and edge case handling in Java. #LeetCode #DSA #Java #CodingPractice #ProblemSolving #SoftwareDevelopment #LearningInPublic #LeetCode75
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 29 📌 Problem: Isomorphic Strings 💻 Language: Java 🧠 Concept Used: HashMap + Bidirectional Mapping 🔍 Platform: LeetCode Two strings are isomorphic if characters in one string can be replaced to get the other string with a one-to-one mapping, while preserving order. Example: s = "egg", t = "add" → ✅ true Approach: ✔ Traverse both strings simultaneously ✔ Use two HashMaps: • One for mapping s → t • One for mapping t → s ✔ Ensure consistency in both directions ✔ If any mismatch occurs → return false Time Complexity: O(n) Space Complexity: O(n) 🔗 Problem Link: https://lnkd.in/gHJ3Vn2a 🔗 Code: https://lnkd.in/gWrRUiN4 #100DaysOfCode #Day29 #Java #DSA #LeetCode #HashMap #Strings #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 83 - LeetCode Journey Solved LeetCode 237: Delete Node in a Linked List in Java ✅ This problem was a bit different from usual linked list questions. Instead of deleting a node in the traditional way, we weren’t given access to the head of the list. That’s what made it interesting. The trick was to think differently. Instead of removing the node directly, copy the value of the next node into the current node and skip the next node. Simple idea, but not obvious at first. This problem really tests your understanding of how linked lists work internally. Key takeaways: • Thinking beyond standard approaches • Understanding pointer manipulation deeply • Writing minimal and efficient code • Strengthening core linked list concepts ✅ All test cases passed ✅ Clean and optimal solution Problems like these remind me that DSA is not just about coding, but about thinking differently 💡 #LeetCode #DSA #Java #LinkedList #ProblemSolving #Algorithms #CodingJourney #InterviewPreparation #Consistency
To view or add a comment, sign in
-
-
Day 14 of my coding journey — Extracting Unique Words using Java Streams Today I explored a clean and efficient way to extract unique words from a string using Java Streams. Instead of writing multiple loops and conditional checks, I leveraged the power of functional programming: Grouped words using a frequency map Filtered out words that appear more than once Collected only truly unique words in a concise pipeline What I really liked about this approach is how readable and expressive the code becomes. It clearly shows what we want to achieve rather than how step-by-step. Key takeaway: Writing optimized code is not just about performance — it’s also about clarity, maintainability, and using the right abstractions. Every day I’m getting more comfortable thinking in terms of streams, transformations, and data flow. If you have alternative approaches or optimizations, I’d love to hear them. #Day14 #Java #CodingJourney #JavaStreams #BackendDevelopment #ProblemSolving #CleanCode
To view or add a comment, sign in
-
-
Day 73 of #90DaysDSAChallenge Solved LeetCode 451: Sort Characters By Frequency Learned an important Java design concept today. Problem Overview: The task was to sort characters in a string based on descending frequency. What confused me initially: Why create a separate Freq class instead of just using HashMap and PriorityQueue directly? Key Learning: PriorityQueue stores one complete object at a time. For this problem, each item needs two pieces of data together: Character Frequency Example: Instead of storing: e and 2 separately We package them as: Freq('e', 2) That custom class acts like a container holding both values in one object, so PriorityQueue can compare and sort them correctly. Why this matters: This taught me that custom classes in Java are often not about complexity, they simply bundle related data into one manageable unit. Alternative approach: We can also use Map.Entry<Character, Integer> instead of creating a custom class, but building Freq makes the logic easier to understand while learning. Today’s takeaway: Not every class is for business logic — sometimes it exists just to package data cleanly. #Java #90DaysDSAChallenge #LeetCode #PriorityQueue #HashMap #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 8 of Java with DSA Journey 🚀 📌 Topic: FizzBuzz (LeetCode 412) 💬 "Clean code is not written by following rules, but by following logic." ✨ What I learned today: 🔹 Condition Priority Matters Checking FizzBuzz (divisible by both 3 & 5) first is crucial. Order defines correctness. 🔹 String Handling Used Integer.toString(i) for clean output formatting. 🔹 Code Readability Even simple problems test how clearly you structure your logic. 🔹 Complexity Awareness ⏱ Time Complexity: O(n) 📦 Space Complexity: O(1) (excluding output list) 🧠 Problem Solved: ✔️ FizzBuzz 🎨 Visualizing the Logic (Decision Tree) Each number flows through conditions like a filter. It stops at the first true condition, which makes ordering critical. 💡 Key Insight: FizzBuzz may look simple, but it teaches precise logical structuring and modular arithmetic (%). 👉 The “15 Test”: If we check i % 3 == 0 first, 15 becomes "Fizz" and skips "Buzz". By checking (i % 3 == 0 && i % 5 == 0) first, we correctly get "FizzBuzz". ⚡ Interview Insight (Scalability Twist): What if we add a new condition like 7 → "Bazz"? Instead of messy if-else, use string concatenation: String currentStr = ""; if (i % 3 == 0) currentStr += "Fizz"; if (i % 5 == 0) currentStr += "Buzz"; if (currentStr.isEmpty()) currentStr += i; answer.add(currentStr); ✅ Easier to extend ✅ Cleaner logic ✅ More maintainable 🔑 Takeaway: Consistency beats complexity. Showing up daily builds real problem-solving skills. #DSA #LeetCode #Java #CodingJourney #ProblemSolving #Day8 #CleanCode #SoftwareEngineering #FizzBuzz #Array #InterviewPrep #Optimization #MCA #lnct #100DaysOfCode #SoftwareEngineering #InPlaceAlgorithms #TechLearning #JavaDeveloper
To view or add a comment, sign in
-
-
Today I worked on a problem that involved finding the maximum count of positive and negative numbers in a sorted array. Key idea: Used Binary Search to efficiently find: The first positive number The first non-negative number From this, we can calculate: Count of positive numbers Count of negative numbers Why Binary Search? Because the array is sorted, it helps reduce time complexity to O(log n) instead of scanning the entire array. What I learned: How to apply binary search beyond just finding elements How to think in terms of boundaries (first occurrence logic) Writing clean and optimized Java code 📌 Problem-solving is not just about coding, it's about thinking efficiently. Looking forward to learning more and improving every day! #Java #DSA #BinarySearch #CodingJourney #ProblemSolving #LearningEveryday
To view or add a comment, sign in
-
-
🚀 Mastering Java Through LeetCode 🧠 Day 22 of My DSA Journey Today I solved an interesting matrix-based problem that improved my understanding of arrays and comparison logic. 📌 LeetCode Problem Solved Today: 2352 – Equal Row and Column Pairs Problem Statement: Given an n x n matrix, find how many pairs (row, column) are exactly the same. A pair is valid only if both contain the same elements in the same order. 🧠 Key Idea: Compare each row with every column Check element-by-element equality Count all matching pairs 🔍 Example: Input: [[3,2,1], [1,7,6], [2,7,7]] Output: 1 Matching Pair: Row 2 = Column 1 → [2,7,7] ⚙️ Approach: Traverse all rows Build each column dynamically Compare row[i][k] with column[k][j] If all elements match → increment count ⏱️ Time Complexity: O(n³) (Optimized solution using HashMap possible in O(n²)) What I Learned: Matrix traversal techniques Row vs Column comparison logic Importance of nested loops in grid problems 🔥 Consistency is the key! Every day one problem closer to my goal of becoming a Software Engineer #LeetCode #DSA #Java #CodingJourney #100DaysOfCode #SoftwareEngineer #ProblemSolving #Learning #Tech
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