🚀 Java Practice: Longest Substring Without Repeating Characters Today I practiced a classic string problem in Java – finding the Longest Substring Without Repeating Characters. 🔹 Problem Statement: Given a string, find the longest substring that does not contain any repeating characters. 🔹 Approach I Used: I implemented a simple nested loop approach: Start checking substring from each index. Keep adding characters until a duplicate character appears. If a duplicate is found, break the loop. Track the maximum length substring during iteration. 💡 Key Concepts Used: String manipulation Nested loops indexOf() method Conditional logic 🧠 Why this problem is useful? This problem helps strengthen understanding of strings, loops, and algorithmic thinking, which are very important for coding interviews and problem solving. 📌 Example Input: "tessdfgteststest" 📌 Output: Longest substring without repeating characters. #Java #DSA #CodingPractice #ProblemSolving #JavaDeveloper #Programming #LearningJourney
Java Longest Substring Without Repeating Characters
More Relevant Posts
-
How does Java manage memory without pointers? String str = new String("Hello"); str = null; When the reference is removed, the object is not deleted immediately. It simply becomes eligible for Garbage Collection. 👉 Eligibility ≠ Immediate deletion Java’s Garbage Collector automatically cleans such objects in the background, making memory management easier and safer. 💡 Understanding this concept helps in writing better and more efficient code. #Java #Programming #JavaDeveloper #Coding #ComputerScience #MemoryManagement
To view or add a comment, sign in
-
-
☕ Java Interview Question 📌 When is ArrayStoreException thrown? ArrayStoreException occurs when you try to store an incompatible data type in an array. 🔹 Why it happens: ✔ Arrays in Java are type-safe at runtime ✔ Storing a different object type than the array’s actual type triggers this exception 🔹 Example Scenario: ✔ Assigning an Integer into an array declared as Double[] ✔ The compiler may allow it (due to polymorphism), but it fails at runtime 🔹 Key Insight: ✔ Happens during runtime, not compile time ✔ Common in cases involving inheritance and object arrays 💡 In Short: ArrayStoreException ensures type safety by preventing invalid object assignments in arrays 🚀 👉For Java Course Details Visit : https://lnkd.in/gwBnvJPR . #Java #CoreJava #ExceptionHandling #Programming #InterviewPreparation #TechLearning #AshokIT
To view or add a comment, sign in
-
-
🚀 **Day 4 of My DSA Journey in Java** Today, I took my first real step into writing Java programs and understanding how code actually works behind the scenes. 🔹 Learned about **functions/methods** — reusable blocks of code designed to perform specific tasks, along with the concept of input and output. 🔹 Understood the importance of the **main() function** — the entry point where every Java program begins execution. 🔹 Wrote my first **Hello World program** using `System.out.println()` 🎉 🔹 Explored the difference between `print` and `println` for output formatting. 🔹 Learned how to use **comments** (`//` and `/* */`) to make code more readable and maintainable. 🔹 Got introduced to the structure of classical Java syntax like `public static void main`. One key takeaway: not everything needs to be mastered instantly — some concepts are okay to understand at a basic level now and explore deeply later. Slowly building consistency and strengthening my fundamentals 💻✨ #DSA #Java #LearningJourney #Coding #Programming #Beginners #Consistency
To view or add a comment, sign in
-
🔥 Day 20: Thread Lifecycle in Java Understanding thread lifecycle is key to mastering multithreading 👇 🔹 What is Thread Lifecycle? 👉 It defines the different states a thread goes through during its execution. 🔹 Thread States in Java 1️⃣ NEW 👉 Thread is created but not started Thread t = new Thread(); 2️⃣ RUNNABLE 👉 Thread is ready or running (after start()) 3️⃣ BLOCKED 👉 Waiting to acquire a lock (synchronization) 4️⃣ WAITING 👉 Waiting indefinitely for another thread (e.g., wait()) 5️⃣ TIMED_WAITING 👉 Waiting for a specific time (e.g., sleep(1000)) 6️⃣ TERMINATED 👉 Thread execution is completed 🔹 Simple Example class MyThread extends Thread { public void run() { System.out.println("Thread Running..."); } } public class Main { public static void main(String[] args) { MyThread t = new MyThread(); System.out.println(t.getState()); // NEW t.start(); System.out.println(t.getState()); // RUNNABLE } } 🔹 Lifecycle Flow NEW → RUNNABLE → (BLOCKED / WAITING / TIMED_WAITING) → TERMINATED 🔹 Key Points ✔ start() → moves thread to RUNNABLE ✔ sleep() → TIMED_WAITING ✔ wait() → WAITING ✔ Lock issues → BLOCKED 💡 Pro Tip: Thread state may change quickly — don’t rely on exact timing in real systems. 📌 Final Thought: "Threads have a life cycle — understanding it helps you control execution." #Java #Multithreading #ThreadLifecycle #Programming #JavaDeveloper #Coding #InterviewPrep #Day20
To view or add a comment, sign in
-
-
🔥 Serialization & Deserialization in Java A very important concept for saving and transferring objects in Java 👇 🔹 1. Serialization 👉 Converting an object into a byte stream so it can be saved to a file or sent over a network. ✔ Used for file storage ✔ Used in networking ✔ Implemented using "Serializable" interface 🔹 2. Deserialization 👉 Converting the byte stream back into an object. ✔ Restores object state ✔ Used when reading from file/network 💻 Simple Example: // Serialization ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("data.txt")); oos.writeObject(s1); oos.close(); // Deserialization ObjectInputStream ois = new ObjectInputStream(new FileInputStream("data.txt")); Student s2 = (Student) ois.readObject(); ois.close(); 📌 Key Points: ✔ Class must implement "Serializable" ✔ Use "ObjectOutputStream" → write object ✔ Use "ObjectInputStream" → read object ✔ "transient" keyword → skip fields 📦 Real-Life Analogy: Serialization = Packing an object into a box Deserialization = Unpacking it back 💡 Pro Tip: Always define "serialVersionUID" to avoid version mismatch issues 📌 Final Thought: "Serialization turns objects into data. Deserialization brings them back to life." #Java #Serialization #Deserialization #JavaDeveloper #Programming #Coding #InterviewPrep #BackendDevelopment
To view or add a comment, sign in
-
-
--->> Understanding Inheritance in Java & Its Types **Inheritance is a fundamental concept in Object-Oriented Programming (OOP) that allows one class to acquire the properties and behaviors of another class. √ What is Inheritance? It is the process where a child class inherits variables and methods from a parent class using the extends keyword. ~Why is it Important? ✔️ Code reusability ✔️ Reduced development time ✔️ Better maintainability ✔️ Cleaner and scalable design @ Types of Inheritance in Java 1️⃣ Single Inheritance 2️⃣ Multilevel Inheritance 3️⃣ Hierarchical Inheritance 4️⃣ Hybrid (combination of types) # Important Notes 🔸 Java does NOT support multiple inheritance using classes ➡️ Because of the Diamond Problem (ambiguity in method resolution) 🔸 Cyclic inheritance is not allowed ➡️ Prevents infinite loops in class relationships 💻 Code Example (Single Inheritance) Java class Parent { void show() { System.out.println("This is Parent class"); } } class Child extends Parent { void display() { System.out.println("This is Child class"); } } public class Main { public static void main(String[] args) { Child obj = new Child(); obj.show(); // inherited method obj.display(); // child method } } 👉 Here, the Child class inherits the show() method from the Parent class. -->> Real-World Example Think of a Vehicle system 🚗 Parent: Vehicle Child: Car, Bike All vehicles share common features like speed and fuel, but each has its own unique behavior. @ Key Takeaway Inheritance helps you avoid code duplication and build efficient, reusable, and scalable application TAP Academy #Java #OOP #Inheritance #Programming #JavaDeveloper #Coding #SoftwareDevelopment #LearnJava
To view or add a comment, sign in
-
-
📒 Day 27: final Keyword in Java 🔥 Java’s way of saying: “Modify me? Compile error loading…” 😎 In Java, the final keyword is used to apply restrictions on variables, methods, and classes to ensure immutability and controlled usage in object-oriented programming. 👉 Uses of final keyword: » 🔹 final variable → value cannot be changed once assigned » 🔹 final method → cannot be overridden in a subclass » 🔹 final class → cannot be extended or inherited 💡 Conclusion: The final keyword helps in achieving security, consistency, and controlled design in Java applications. #Java #CoreJava #OOP #Programming #Coding #LearnInPublic #100DaysOfCode #SoftwareDevelopment #JavaDeveloper #CodingJourney #final #finalkeyword
To view or add a comment, sign in
-
🚀 Mastering Arrays and Strings in Java 🚀 Arrays and strings are fundamental in Java, but knowing how to efficiently manipulate them can take your coding skills to the next level. From sorting arrays to manipulating strings, these essential operations are key to writing clean and efficient code. 🔗 Read more: https://lnkd.in/dGh5wPr8 #Java #Coding #ProgrammingTips #JavaDevelopment #Arrays #Strings #TechTips
To view or add a comment, sign in
-
☕ Java Interview Question 📌 What are the drawbacks of Garbage Collection? Garbage Collection simplifies memory management, but it comes with some trade-offs ⚖️ 🔹 Key Drawbacks: ✔ Performance Pauses – GC can cause application pauses, impacting performance ✔ Non-Deterministic Behavior – Hard to predict when GC will run ✔ Increased Memory Usage – Frequent object creation/destruction can add overhead 💡 In Short: While GC improves developer productivity, it may introduce latency and unpredictability in performance-critical applications 🚀 👉For Java Course Details Visit : https://lnkd.in/gwBnvJPR . #Java #GarbageCollection #Programming #TechInterview #BackendDevelopment #Learning #AshokIT
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