🚀 Day 8 of My 90 Days Java Full Stack Challenge Today, I practiced two interesting String problems that helped me strengthen my understanding of string manipulation and logical thinking in Java. 🧩 1️⃣ Reverse Words in a Sentence Input: "Java is fun" Output: "fun is Java" 🔎 Approach: Traverse from the end Extract words Rebuild the sentence in reverse order Handle edge cases like multiple spaces 💡 Learned how to manage string traversal without relying completely on inbuilt methods. 🧩 2️⃣ Check Rotation of String Example: "abcd" & "cdab" 🔎 Key Insight: If s2 is a rotation of s1, then s2 must be a substring of (s1 + s1). ✔ Length check first ✔ Then verify using substring logic This problem improved my understanding of pattern recognition in strings. 🧠 Key Takeaways: Two-pointer & traversal techniques Importance of handling edge cases Writing optimized logic instead of brute force Understanding how string concatenation helps solve rotation problems 📅 Next step: Continue exploring more intermediate-level string problems. Consistency > Motivation 💪 #90DaysJavaFullStack #Java #StringManipulation #ProblemSolving #LearningInPublic #DeveloperJourney
Java String Manipulation Challenge: Reversing Words & Rotation
More Relevant Posts
-
🚀 Day 2/30 – Java DSA Challenge 🔎 Problem 12: 1299. Replace Elements with Greatest Element on Right Side (LeetCode – Easy) Solved another array traversal problem today 🔥 This problem focuses on understanding how to compare elements on the right side of an array. 🧠 Problem Statement Given an array arr, replace every element with the greatest element among the elements to its right. ✔ Replace the last element with -1 ✔ Return the modified array 💡 Example Input: [17,18,5,4,6,1] Output: [18,6,6,6,1,-1] Explanation: Each element is replaced by the maximum element present to its right. 👨💻 Approach (Brute Force) ✔ Traverse each index ✔ For every element, check all elements to its right ✔ Find the maximum among them ✔ Replace current element with that maximum ✔ For the last element → assign -1 Since constraints are manageable, this approach works. ⏱ Time Complexity: O(n²) – Nested loops 📦 Space Complexity: O(1) – In-place modification 📌 Key Learning: Understanding brute-force solutions is important before moving to optimized right-to-left traversal (which can reduce it to O(n)). Day 2 progressing consistently 💪🔥 Small steps every day lead to big improvements 🚀 #Day2 #30DaysOfCode #Java #DSA #LeetCode #ArrayProblems #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Java Deep Dive — Daemon Threads (Something many developers overlook) In Java, not all threads behave the same way. There are two types: • User Threads • Daemon Threads The JVM keeps running as long as at least one user thread is alive. But daemon threads work differently. They are background service threads used for supporting tasks like: • Garbage Collection • Monitoring • Background cleanup If all user threads finish, the JVM will terminate immediately, even if daemon threads are still running. Example: Java Example Thread thread = new Thread(() -> { while(true){ System.out.println("Running..."); } }); thread.setDaemon(true); thread.start(); If the main thread finishes, this daemon thread will not keep the JVM alive. Important rule: You must call "setDaemon(true)" before starting the thread, otherwise Java throws "IllegalThreadStateException". 💡 Key Insight Daemon threads are useful for background tasks that should not block application shutdown. #Java #Multithreading #BackendDevelopment #SoftwareEngineering #LearningInPublic
To view or add a comment, sign in
-
LeetCode Problem || Find Unique Binary String (1980)🚀 Today I solved the problem "Find Unique Binary String" using Java. 🔹 Problem: We are given an array of n binary strings, each of length n. The goal is to return a binary string of length n that does not exist in the array. 🔹 Approach (Diagonal Flip Technique): The idea is simple but powerful: Traverse the array using index i. Look at the i-th character of the i-th string (nums[i][i]). Flip the bit (0 → 1, 1 → 0). Append it to a result string. 💡 Time Complexity: O(n) Practicing problems like this strengthens logical thinking and problem-solving skills. #LeetCode #Java #CodingPractice #ProblemSolving #DSA
To view or add a comment, sign in
-
-
🚀 Day 9 of My 90 Days Java Full Stack Challenge Today, I focused on strengthening my understanding of String manipulation, Stack implementation, and Exception Handling in Java. 🧩 Problems Practiced ✔ String Compression Input: "aaabbc" Output: "a3b2c1" Learned how to implement run-length encoding logic using StringBuilder efficiently in O(n) time. ✔ Valid Parentheses Input: "({[]})" Used Stack (including manual stack implementation) to validate proper nesting of brackets. Improved understanding of LIFO and stack-based problem solving. ⚙ Java Concept Practiced ✔ Exception Handling try–catch blocks finally block usage Checked vs Unchecked exceptions Why exceptions shouldn’t be used for normal control flow 🧠 Key Takeaways Importance of handling edge cases Writing optimized code instead of brute force Understanding internal working of Stack Writing cleaner and more structured Java logic Consistency matters more than intensity 💪 #90DaysJavaFullStack #Java #StringManipulation #Stack #ExceptionHandling #LearningInPublic #DeveloperJourney
To view or add a comment, sign in
-
Day 3/50 | #50DaysOfCode 📍 Platform: LeetCode 💻 Language: Java ✅ 977. Squares of a Sorted Array (Easy) Today’s problem focused on array manipulation and sorting logic. It helped me understand how negative numbers affect order after squaring and how to maintain sorted order efficiently. 🔎 Approach: Traverse the array and calculate the square of each element Store the squared values in a new array Sort the new array in non-decreasing order Return the sorted squared array 📌 Example: Input: nums = [-4, -1, 0, 3, 10] Output: [0, 1, 9, 16, 100] This problem strengthened my understanding of arrays, sorting, and handling negative values in Java. #DSA #LeetCode #Java #CodingJourney #ProblemSolving #Consistency #LearningJourney #50DaysOfCode #LinkedIn
To view or add a comment, sign in
-
-
🚀 Container With Most Water | Java | Two Pointer Approach I solved the “Container With Most Water” problem using an optimized Two Pointer technique in Java. The goal is to find two lines that together with the x-axis form a container, such that the container holds the maximum amount of water. 🧠 Approach: Start with two pointers at both ends of the array. Calculate the width between them. The height is determined by the smaller of the two values. Update the maximum area. Move the pointer pointing to the smaller height inward. This greedy strategy works because the area depends on both width and minimum height, and moving the smaller height gives a chance to find a larger area. ⏱ Time Complexity: O(n) 📦 Space Complexity: O(1) Practicing DSA problems daily to improve logical thinking and optimization skills. #Java #DSA #TwoPointer #ProblemSolving #CodingJourney #LeetCode #DataStructures
To view or add a comment, sign in
-
-
Day 5/50 | #50DaysOfCode 📍 Platform: LeetCode 💻 Language: Java ✅ 1662. Check If Two String Arrays are Equivalent (Easy) Today’s problem focused on string concatenation and comparison. It helped reinforce my understanding of arrays, string handling, and equality checks. 🔎 Approach: Concatenate all elements of word1 to form a single string Concatenate all elements of word2 to form another string Compare the two resulting strings If both strings are equal, return true, otherwise false 📌 Example: Input: word1 = ["ab","c"], word2 = ["a","bc"] Output: true Explanation: word1 → "ab" + "c" = "abc" word2 → "a" + "bc" = "abc" Both strings are equal. This problem strengthened my understanding of string manipulation and array traversal in Java. #DSA #LeetCode #Java #CodingJourney #ProblemSolving #Consistency #LearningJourney #50DaysOfCode #LinkedIn
To view or add a comment, sign in
-
-
Something weird happened while I was debugging a Java program today. I had a simple program running with multiple threads, and I printed the thread names just to see what was happening. The output looked something like this: main http-nio-8080-exec-1 http-nio-8080-exec-2 ForkJoinPool.commonPool-worker-3 At first I ignored it. But then I started wondering… Where are all these threads actually coming from? I didn’t create them. After digging a bit deeper, I realized something interesting. Modern Java applications are constantly using different thread pools behind the scenes. For example: • The web server creates request threads • "CompletableFuture" uses the ForkJoinPool • Some frameworks create background worker threads • The JVM itself runs internal service threads Which means even a “simple” backend service may actually be running dozens of threads at the same time. It made me realize something: A lot of complexity in backend systems isn’t in the code we write — it’s in the systems running around our code. Now I’m a lot more curious about what’s actually happening inside the JVM when our apps run. #Java #BackendEngineering #SpringBoot #SoftwareEngineering #LearningInPublic
To view or add a comment, sign in
-
Day 3/50 | #50DaysOfCode 📍 Platform: LeetCode 💻 Language: Java ✅ 1768. Merge Strings Alternately (Easy) Today’s problem focused on string manipulation and efficient merging techniques. It helped reinforce my understanding of string traversal and handling different string lengths. 🔎 Approach: Use a loop to iterate through both strings simultaneously Append characters alternately from word1 and word2 Check if one string is longer than the other Append the remaining characters at the end Return the final merged string 📌 Example: Input: word1 = "abc", word2 = "pqr" Output: "apbqcr" This problem improved my understanding of string handling, indexing, and building efficient logic using Java. #DSA #LeetCode #Java #CodingJourney #ProblemSolving #Consistency #LearningJourney #50DaysOfCode #LinkedIn
To view or add a comment, sign in
-
-
🚀Java practice - Day 87 Completed! 👍 Problem: Sum of Squares of Special Elements Language: Java Today’s problem was about identifying special elements in a 1-indexed array. An element is considered special if its index divides the length of the array (n % i == 0). The task was to calculate the sum of the squares of such elements.✨ #Day87 #Java #LeetCode #Arrays #ProblemSolving #DailyCoding #Consistency #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