Day 46/100 – #100DaysOfCode 🚀 | #Java #BFS #Graph ✅ Problem Solved: Word Ladder (LeetCode 127) 🧩 Problem Summary: You are given a beginWord, endWord, and a list of words. You must transform beginWord → endWord by changing one character at a time, where each intermediate word must exist in the dictionary. Return the minimum number of transformations. 💡 Approach Used: Used Breadth-First Search (BFS) because: We need the shortest path in terms of transformation steps. Each word is considered a node in a graph. Key Steps: Pre-processed all words into generic pattern groups (e.g., h*t → hot, hit, etc.). Performed BFS from beginWord until reaching endWord. Counted transformation depth as solution. ⚙️ Time Complexity: O(N × L²) 📦 Space Complexity: O(N × L) ✨ Takeaway: This problem is an excellent example of how BFS can be used for shortest transformation sequences in word-graphs. #Java #LeetCode #Graph #BFS #ProblemSolving #100DaysOfCode #CodingChallenge
Solved Word Ladder with BFS in Java for LeetCode 127
More Relevant Posts
-
Day 70 of #100DaysOfJavaFullStack 📌 Topic: Stack, Queue, and Map Interfaces in Java Today I learned about three important interfaces in Java’s Collection Framework — Stack, Queue, and Map. 1️⃣ Stack Interface :- ✅ What is Stack Interface? ✅ Syntax: ✅ Hierarchy of Stack ✅ Key Points of Stack ✅ Common Methods in Stack ✅ Implementation of Stack Interface 2️⃣ Queue Interface :- ✅ What is Queue? ✅ Syntax: ✅ Hierarchy of Queue ✅ Key Points of Queue ✅ Common Methods in Queue ✅ Implementation of Queue Interface 3️⃣ Map Interface :- ✅ What is Map Interface? ✅ Syntax: ✅ Hierarchy of Map ✅ Key Points of Map ✅ Common Methods in Map ✅ Implementation of Map Interface ✅ Difference Between List, Set, and Map 🎯 Thanks to PRATIKSHA INDROL Mam for explaining Stack, Queue, and Map with practical examples that clarified how data structures manage data efficiently. #Day70 #Java #CollectionFramework #Stack #Queue #Map #CoreJava #LearningToCode #FortuneCloud #CravitaTechnology #100DaysChallenge #JavaFullStack
To view or add a comment, sign in
-
🚀 Just implemented a custom Vector<T> class in Java — a dynamic array structure that grows automatically as elements are added. It supports key operations like push_back, pop_back, front, back, clear, and more — all while practicing the concepts of generics, dynamic memory allocation, and data encapsulation. Rebuilding core data structures from scratch is a great way to understand how tools like ArrayList work internally. 💻 #Java #DSA #LearningByDoing #CodingJourney #DataStructures Nohit Singh,Shreyash Khedekar,Anshuman Singh,Arpit Jain
To view or add a comment, sign in
-
Day 46/100 Problem Statement : You are given an integer array target. You have an integer array initial of the same size as target with all elements initially zeros. In one operation you can choose any subarray from initial and increment each value by one. Return the minimum number of operations to form a target array from initial. The test cases are generated so that the answer fits in a 32-bit integer. Input: target = [1,2,3,2,1] Output: 3 Solution : https://lnkd.in/gsXFvUr3 public int minNumberOperations(int[] target) { final int n=target.length; int ans=target[0]; for(int i=1; i<n; i++) ans+=Math.max(target[i]-target[i-1], 0); return ans; } #100DaysDSA #100DaysOfCode #Java #Leetcode #Neetcode #Neetcode250 #TUF
To view or add a comment, sign in
-
#100DaysOfCode – Day 73 String Manipulation Problem: Valid Anagram (LeetCode #242) Task: Given two strings s and t, return true if t is an anagram of s, otherwise false. Example: Input: s = "anagram", t = "nagaram" → Output: true Input: s = "rat", t = "car" → Output: false My Approach:- Method 1 – Sorting Converted both strings into character arrays. Sorted them and compared if equal, they’re anagrams! Time Complexity: O(n log n) Method 2 – Frequency Count (Optimized) Counted occurrences of each character in s and t. If every count matches, it’s a valid anagram. Time Complexity: O(n) | Space: O(1) String problems may look simple, but optimizing from sorting to counting makes a huge difference. Small logic shifts often lead to big performance gains! #100DaysOfCode #Java #ProblemSolving #LeetCode #CodingJourney #takeUforward #DataStructures #Algorithms #StringManipulation #GeeksForGeeks #CodeNewbie
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 77 Delete in a Doubly Linked List Problem: Given a doubly linked list and an integer x, remove the node at position x (1-indexed) and return the head of the updated list. Example: Input: 1 <-> 2 <-> 3 <-> 4, x = 3 Output: 1 <-> 2 <-> 4 My Approach: 1️⃣ Handled edge cases deleting the head or an empty list. 2️⃣ Traversed to the node at position x. 3️⃣ Updated both prev and next pointers to unlink the node cleanly. Time Complexity: O(N) Space Complexity: O(1) Understanding pointer manipulation in linked lists builds the foundation for mastering advanced data structures. Every prev and next link matters! #100DaysOfCode #Java #ProblemSolving #DSA #GeeksforGeeks #LinkedList #Pointers #TakeUForward #CodeNewbie #CodingJourney
To view or add a comment, sign in
-
-
𝗕𝗲𝗵𝗶𝗻𝗱 𝘁𝗵𝗲 𝗦𝗰𝗲𝗻𝗲𝘀 𝗼𝗳 𝗝𝗮𝘃𝗮 𝗔𝗿𝗿𝗮𝘆𝗟𝗶𝘀𝘁! Today, I implemented a 𝗗𝘆𝗻𝗮𝗺𝗶𝗰 𝗔𝗿𝗿𝗮𝘆 in Java — building the logic from scratch to understand how ArrayList actually works under the hood. ⚙️ This exercise gave me hands-on exposure to how resizing, shifting, and accessing elements are efficiently handled in dynamic data structures. 𝗛𝗲𝗿𝗲’𝘀 𝘄𝗵𝗮𝘁 𝗜 𝗶𝗺𝗽𝗹𝗲𝗺𝗲𝗻𝘁𝗲𝗱 👇 🔹 add(element) — to append new items dynamically 🔹 add(index, element) — to insert at a specific position 🔹 get(index) — to fetch values efficiently 🔹 set(index, element) — to replace existing elements 🔹 remove(index/element) — to delete items and shift elements 🔹 contains(element) — to check for existence 🔹 isEmpty() & clear() — to manage and reset the structure 𝗜𝗺𝗽𝗹𝗲𝗺𝗲𝗻𝘁𝗮𝘁𝗶𝗼𝗻 𝗖𝗼𝗱𝗲 : https://lnkd.in/gXEfwXvf 📘 𝗞𝗲𝘆 𝗧𝗮𝗸𝗲𝗮𝘄𝗮𝘆: Recreating ArrayList from scratch deepened my understanding of how memory reallocation, indexing, and dynamic resizing make it one of the most powerful data structures in Java’s Collection Framework. Learning the “how” behind the “what” truly builds stronger foundations. 💪 #Java #DataStructures #ArrayList #CodingJourney #LearningByDoing #SoftwareEngineering #DSA #100DaysOfCode
To view or add a comment, sign in
-
-
The Two Pillars: Primitives vs. References Java clearly separates its data types into two main categories: Primitive Types: These hold the actual value directly. They are simple, memory-efficient, and stored in the Stack Memory. They are the 'nuts and bolts' of computation. Numeric: byte, short, int, long (for whole numbers), float, double (for decimals). Character: char (for a single character). Logical: boolean (for true or false). Reference Types (Objects): These do not store the actual data directly. Instead, they store a reference (a memory address) pointing to the object's location in the Heap Memory. Examples include String, Arrays, and any custom class you create (like Scanner or a custom User class). #Java #development #datatypes #aoftwareengineering #OOPs
To view or add a comment, sign in
-
-
🗓 Day 7 / 100 – #100DaysOfLeetCode 🔢 Problem 2536: Increment Submatrices by One Today’s challenge involved processing multiple submatrix increment queries on an n x n matrix, initially filled with zeros. 🧠 My Approach Instead of updating every cell inside each submatrix (which would be too slow for up to 10⁴ queries), I used a row-wise difference array technique. For each query [r1, c1, r2, c2]: Increment prefix[row][c1] Decrement prefix[row][c2+1] (if within bounds) This allows efficient marking of increments. Later, prefix-summing each row reconstructs the final matrix. ⏱ Time Complexity O(q × n) where q = number of queries (We touch r2 - r1 + 1 rows per query) 💾 Space Complexity O(n²) for the prefix matrix #LeetCode #Java #ProblemSolving #CodingChallenge #100DaysOfCode #DSA #LearningEveryday
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