Java DSA Fundamentals and Problem Solving with LeetCode Solutions

🚀 Day 3 / 100 – #100DaysOfCode Today’s focus was on Java backend fundamentals and deep DSA understanding. ⸻ 🔧 Development (Java) 📌 Local DB using JSON • Used JSON as a lightweight local database • Applied Java Serialization to convert objects ↔ JSON • Linked serialized JSON data with Java classes for persistent storage • Helpful for small-scale apps where a full DB is overkill 🧠 DSA Progress 1️⃣ Set Matrix Zeroes Problem: If an element is 0, set its entire row and column to 0 Optimized Approach (O(1) Space): • Use first row & first column as markers • If matrix[i][j] == 0: • Mark matrix[i][0] = 0 • Mark matrix[0][j] = 0 • Maintain two flags: • rowZero → whether first row contains 0 • colZero → whether first column contains 0 • Traverse matrix (excluding first row/column) and update based on markers • Finally, update first row & column using flags 2️⃣ Word Search Problem: Check if a word exists in a 2D board Approach: • Start DFS from cells matching first character • Move in 4 directions (up, down, left, right) • Use backtracking: • Mark cell as visited • Revert after recursive call • Stop early if index exceeds word length or characters mismatch. 3️⃣ Find the Duplicate Number Problem: Find the single duplicate in an array of size n+1 Efficient Approach (Index Marking): • For each element x: • Go to index abs(x) • If value at that index is already negative → duplicate found • Else, mark it negative My solution links- https://lnkd.in/gf4b-E6K https://lnkd.in/gNv9gtgB https://lnkd.in/gGatDNSK 📌 Consistency > Motivation. Building logic daily, one problem at a time. #100DaysOfCode #Day3 #Java #DSA #ProblemSolving #LeetCode #BackendDevelopment #LearningInPublic #SoftwareEngineer #Consistency #PlacementPrep

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories