🚀 Day 31 of #128DaysOfCode 🔹 Problem Insight: Given a string with extra spaces, the goal was to reverse the order of words while ensuring: - No leading or trailing spaces - Only a single space between words 🔹 What I Learned: - How to handle multiple spaces efficiently - Importance of string traversal from end to start - Using StringBuilder for optimized string operations - Avoiding built-in shortcuts like "split()" to strengthen logic 🔹 Approach: Instead of relying on inbuilt functions, I manually parsed the string: - Skipped unnecessary spaces - Extracted words one by one - Rebuilt the string in reverse order 🔹 Key Takeaway: Sometimes, avoiding easy methods helps build deeper problem-solving skills — exactly what interviews test! 💡 Consistency is the real game. One step closer to becoming a better developer every single day 💻🔥 #Java #DSA #CodingJourney #Consistency #PlacementPreparation #LearningInPublic
Reversing Strings in Java with Efficient String Traversal
More Relevant Posts
-
Most people overcomplicate this problem. At first glance, it feels like we need extra space or another array… But the trick is simple: Since the array is sorted, duplicates are always next to each other. Once you notice that, you can solve it in-place using a Two Pointer approach — no extra space needed. Small observation → big optimization. If you’re preparing for coding interviews, this pattern shows up more often than you think. Have you used this approach before? #DSA #TwoPointers #Java #CodingInterview #ProblemSolving #LeetCode #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Started something I've been meaning to do for a while — a dedicated 𝗚𝗶𝘁𝗛𝘂𝗯 𝗿𝗲𝗽𝗼 𝗳𝗼𝗿 𝗟𝗟𝗗 (𝗟𝗼𝘄 𝗟𝗲𝘃𝗲𝗹 𝗗𝗲𝘀𝗶𝗴𝗻) interview prep in Java! 📌 𝗵𝘁𝘁𝗽𝘀://𝗴𝗶𝘁𝗵𝘂𝗯.𝗰𝗼𝗺/𝗱𝗮𝗿𝘀𝗵𝗲𝗲𝗹-𝗿𝗮𝘁𝗵𝗼𝗿𝗲/𝗹𝗹𝗱-𝗷𝗮𝘃𝗮-𝗽𝗿𝗮𝗰𝘁𝗶𝗰𝗲 The goal? 50 LLD projects, all in one place — designed the way interviewers actually expect them. Starting from the classics like: ✅ Tic-Tac-Toe (done — with Strategy pattern, undo & bot support) ⏳ Snake & Ladder, Parking Lot, Vending Machine... And going all the way up to real-world system designs: 🔧 API Throttling System 📞 Truecaller 💼 LinkedIn-style features ...and 40+ more. Every project follows: → SOLID principles → Strategy & Builder patterns → Clean package structure (models, strategies, exceptions) → Interview-style driver code — no Scanner, just real scenarios If you're prepping for LLD rounds, this could save you hours of scattered searching. ⭐ 𝗦𝘁𝗮𝗿 or 🍴 𝗙𝗼𝗿𝗸 𝗶𝘁 — all 50 projects will land here as I build them out weekly. Would love feedback from folks who've cracked LLD rounds — what problems did you face that I should cover? Drop them in the comments! 👇 #Java #LLD #SystemDesign #InterviewPrep #DesignPatterns #OpenSource
To view or add a comment, sign in
-
Backend Interview Prep in 2026 👇 Most people: ❌ Watch random videos ❌ Read scattered blogs ❌ Forget everything in 2 days Smart people: ✅ Follow structured learning ✅ Practice real scenarios ✅ Focus on system design That’s exactly why I created this 👇 📘 Backend Interview Master PDF 👉 Link: https://lnkd.in/gbF6u9ni 🎁 Use JAVA25 for 15% OFF. Don’t prepare hard. Prepare smart. #Java #Backend #SystemDesign
To view or add a comment, sign in
-
🚀 Spring Boot Interview Concept: @PathVariable vs @RequestParam vs @RequestBody Understanding when to use each annotation is very important for designing clean REST APIs 👇 🔹 @PathVariable 👉 Used to identify a specific resource 📌 Example: /users/10 → Fetch user with ID = 10 🔹 @RequestParam 👉 Used for filtering, searching, or optional inputs 📌 Example: /users?role=admin&active=true 🔹 @RequestBody 👉 Used to send complete object data (mostly in POST/PUT APIs) 📌 Example (JSON): { "name": "Ankit", "age": 25 } One-Line Rule to Remember: @PathVariable → resource identify @RequestParam → filter/search @RequestBody → send full object #Java #SpringBoot #BackendDevelopment #RESTAPI #InterviewPreparation #SoftwareEngineering
To view or add a comment, sign in
-
Here is one the most asked technical interview questions, LeetCode: Longest Substring Without Repeating Characters (medium) Given a string, find the length of the longest substring without repeating characters. 💡 Key idea: Use a sliding window and adjust it whenever a duplicate appears. 🧠 Solution: - Use two pointers to form a window and a hashmap to track character positions. - Move the right pointer through the string. - If a character repeats inside the window, move the left pointer past its last position. - Update the max length at each step. Time Complexity and Space Complexity: O(n) #LeetCode #Algorithms #CodingInterview #SoftwareEngineering #DSA #Java
To view or add a comment, sign in
-
-
Most people solve “Valid Palindrome” like this. Clean the string → reverse → compare. It works… but that’s not what interviewers are looking for. The real test is: 👉 Can you handle messy input? 👉 Can you avoid extra space? 👉 Can you think in constraints? That’s where Two Pointers comes in. Small problem. Big difference in thinking. #DSA #Java #CodingInterview #TwoPointers #ProblemSolving #SoftwareEngineering #TechLearning
To view or add a comment, sign in
-
Spring Boot Interview Series — Post 8 Spring fails when it finds two beans of the same type and doesn't know which to inject. NoUniqueBeanDefinitionException: expected single matching bean but found 2: upiPaymentService, cardPaymentService Two ways to fix this. @Primary - tells Spring to use that bean by default when multiple candidates of the same type exist. @Qualifier - resolves ambiguity when multiple beans of the same type exist. You specify exactly which bean to inject by name. When using constructor injection - which is the recommended approach - @Qualifier goes on the constructor parameter, not the field. Used together - @Primary sets the app-wide default. @Qualifier overrides it at specific injection points. If Spring can't decide which bean to inject, you have two choices - tell it what the default is, or tell it exactly what you want. #SpringBoot #Java #JavaDeveloper #BackendDevelopment #SpringFramework
To view or add a comment, sign in
-
-
🚀 A small #learning from my recent interview In one of my recent interviews, I was asked to write a program to create a deadlock and then explain how to fix it. Honestly, I’ve read about deadlocks before, but writing it during an interview made me think more practically. 𝐓𝐰𝐨 𝐭𝐡𝐫𝐞𝐚𝐝𝐬, 𝐭𝐰𝐨 𝐫𝐞𝐬𝐨𝐮𝐫𝐜𝐞𝐬: Thread 1 locks one resource and waits for the other Thread 2 does the opposite And that’s it… both threads are 𝐬𝐭𝐮𝐜𝐤 𝐟𝐨𝐫𝐞𝐯𝐞𝐫 What I liked about this question is — it’s simple, but it checks how well we understand real-world thread behavior. The discussion didn’t stop at just creating the deadlock. The interviewer was more interested in how I would avoid it. 𝐒𝐨𝐦𝐞 𝐤𝐞𝐲 𝐭𝐚𝐤𝐞𝐚𝐰𝐚𝐲𝐬 𝐟𝐨𝐫 𝐦𝐞: --> Always follow a consistent order while acquiring locks --> Be careful with nested synchronization --> Think about alternatives like tryLock or timeouts It was a good reminder that multithreading is not just about writing code, but about writing safe and predictable code. #Java #Multithreading #Concurrency #JavaDeveloper #BackendDevelopment #SoftwareEngineering #InterviewExperience #TechInterview #CodingInterview #Learning
To view or add a comment, sign in
-
-
𝐉𝐚𝐯𝐚 𝐌𝐮𝐥𝐭𝐢𝐭𝐡𝐫𝐞𝐚𝐝𝐢𝐧𝐠 — 𝐌𝐨𝐬𝐭 𝐃𝐞𝐯𝐞𝐥𝐨𝐩𝐞𝐫𝐬 𝐋𝐞𝐚𝐫𝐧 𝐈𝐭… 𝐁𝐮𝐭 𝐅𝐞𝐰 𝐓𝐫𝐮𝐥𝐲 𝐔𝐧𝐝𝐞𝐫𝐬𝐭𝐚𝐧𝐝 𝐈𝐭. I’ve seen many developers struggle with multithreading in interviews — not because it’s too hard, but because they only learn it theoretically. So I created this simple visual cheat sheet 👇 Here’s what you should ACTUALLY focus on: 🔹 Thread Basics Creating threads is easy: Runnable Callable But knowing when to use which is what matters. 🔹 Thread Lifecycle New → Runnable → Running → Waiting → Terminated 👉 Interviewers LOVE asking this flow with real scenarios. 🔹 Synchronization This is where things get tricky: Race conditions Deadlocks Data inconsistency ✔ Use synchronized / Lock carefully ✔ Keep critical sections minimal 🔹 Executor Framework (Most Important) Stop creating threads manually ❌ Use: ✔ ExecutorService ✔ Thread pools ✔ Future / Callable 👉 This is what real production systems use. 🔹 Inter-thread Communication wait(), notify(), notifyAll() 👉 Not just theory — understand when threads should wait and wake up 🔹 Concurrent Collections ConcurrentHashMap CopyOnWriteArrayList 👉 Essential for multi-threaded applications 🔹 Common Problems ⚠ Deadlock ⚠ Starvation ⚠ Thread leaks 👉 If you can explain EVEN ONE real issue → you stand out in interviews. 💡 Reality: Multithreading is not about writing code… It’s about writing safe + scalable + production-ready code 𝐈𝐟 𝐲𝐨𝐮’𝐫𝐞 𝐬𝐭𝐫𝐮𝐠𝐠𝐥𝐢𝐧𝐠 𝐭𝐨 𝐜𝐫𝐚𝐜𝐤 𝐉𝐚𝐯𝐚 𝐢𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰𝐬 (𝟐–𝟔 𝐲𝐞𝐚𝐫𝐬 𝐞𝐱𝐩𝐞𝐫𝐢𝐞𝐧𝐜𝐞), 𝐃𝐌 𝐦𝐞 𝐩𝐞𝐫𝐬𝐨𝐧𝐚𝐥𝐥𝐲 — 𝐈’𝐥𝐥 𝐠𝐮𝐢𝐝𝐞 𝐲𝐨𝐮 𝐨𝐧𝐞-𝐭𝐨-𝐨𝐧𝐞 𝐰𝐢𝐭𝐡 𝐭𝐡𝐞 𝐫𝐢𝐠𝐡𝐭 𝐚𝐩𝐩𝐫𝐨𝐚𝐜𝐡. #Java #Multithreading #JavaDeveloper #BackendDevelopment #InterviewPreparation #SpringBoot #Concurrency
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