Day 19 of #Leetcode150DaysChallenge Today’s problem: 237. Delete Node in a Linked List Instead of deleting the node directly, we copy the value of the next node into the current node and then skip the next node. This way, the current node effectively becomes the next node, and the original next node gets removed. #LeetCode #DataStructures #Java #ProblemSolving
Delete Node in a Linked List LeetCode Challenge
More Relevant Posts
-
Day 95/200 – LeetCode Challenge. Problem: Remove Duplicates from Sorted List II (Java) Today’s focus was eliminating all duplicate values from a sorted linked list while keeping only distinct nodes. Implemented an efficient two-pointer approach with a dummy node to handle edge cases cleanly. Linked lists require careful pointer management. Dummy nodes simplify boundary conditions. One-pass solution ensures optimal performance. Continuing the 200-day journey, one problem at a time. #LeetCode #Java #CodingChallenge #200DaysOfCode #ProblemSolving
To view or add a comment, sign in
-
-
Day 66 — LeetCode Progress (Java) Problem: Find the Difference of Two Arrays Required: Given two integer arrays, return: Elements present in nums1 but not in nums2 Elements present in nums2 but not in nums1 Idea: Use sets to remove duplicates and quickly check membership. Approach: Convert both arrays into sets Iterate over nums1 set: Add elements not present in nums2 set to result1 Iterate over nums2 set: Add elements not present in nums1 set to result2 Return both lists Time Complexity: O(n + m) Space Complexity: O(n + m) #LeetCode #DSA #Java #HashSet #Arrays #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
#Day85 of #100DaysOfCode Focused on practicing array-based problems with an emphasis on logic and efficiency. Worked on: * Moving zeros to the end of an array * Checking if an array is a palindrome * Calculating the sum of even elements #Java #Arrays #100DaysOfCode
To view or add a comment, sign in
-
-
Day 68/100 Completed ✅ 🚀 Solved LeetCode – Split Array Largest Sum (Java) ⚡ Applied an efficient Binary Search on Answer approach to split the array into k subarrays such that the largest subarray sum is minimized. Instead of trying all possible splits, optimized the solution by searching within the range of maximum element and total sum, and validating using a greedy strategy. 🧠 Key Learnings: Identifying binary search applicability in partition-based problems Defining search space using max element (lower bound) and total sum (upper bound) Using greedy logic to check feasibility of splitting into k subarrays Minimizing the maximum subarray sum through efficient validation 💯 This problem strengthened my understanding of partition problems and reinforced how binary search can be used for optimization rather than direct searching. 🔗 Profile: https://lnkd.in/gaJmKdrA #leetcode #datastructures #algorithms #java #binarysearch #problemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Day 65 — LeetCode Progress (Java) Problem: Find All Numbers Disappeared in an Array Required: Given an array of size n containing numbers in the range [1, n], return all the numbers that are missing from the array. Idea: Compare the expected range [1…n] with the actual elements to identify missing values. Approach: Initialize a set containing all numbers from 1 to n. Traverse the array: Remove each element from the set The remaining elements in the set are the missing numbers. Time Complexity: O(n) Space Complexity: O(n) #LeetCode #DSA #Java #HashSet #Arrays #Algorithms #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
How ConcurrentHashMap Works Internally 1. Core Idea • No global lock • Uses CAS + fine-grained (bucket-level) locking • Allows multiple reads and concurrent writes 2. Structure • Array + buckets • Buckets → Linked List → Tree (if collisions grow) 3. Reads (get) • Completely lock-free • Uses volatile for visibility 👉 Very fast under concurrency 4. Writes (put) • Empty bucket → CAS (no lock) • Non-empty → lock only that bucket 👉 Minimal contention 5. Resizing • Not single-threaded • Multiple threads help rehash 👉 No major pause 6. Why It Scales • Lock-free reads • Localized locking • CAS for fast updates ConcurrentHashMap works because it avoids global locks and minimizes contention 👉 Balance of: • CAS • Bucket-level locks • Parallel resize #SystemDesign #Java #Concurrency #ConcurrentHashMap #BackendEngineering #Scalability #Performance
To view or add a comment, sign in
-
-
Day 72 - Merge Nodes Between Zeros Processing linked list segments to merge values between zero nodes into a single summed node. Approach: • Traverse the list starting after first zero • Accumulate values until next zero • Create a new node with the sum • Repeat for all segments Key Insight: Treat zero values as boundaries to define segments Time Complexity: O(n) Space Complexity: O(1) #Day72 #LeetCode #Java #CodingPractice #TechJourney #DSA #LinkedList
To view or add a comment, sign in
-
-
🚀 Day 35 of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Valid Anagram Problem Insight: Given two strings, check if one is an anagram of the other. Approach: • First, check if the strings have the same length; if not, return false • Convert both strings to character arrays • Sort both arrays • Compare the sorted arrays — if equal, the strings are anagrams Time Complexity: • O(n log n) — due to sorting the arrays Space Complexity: • O(n) — for the character arrays Key Learnings: • Sorting is a simple and effective way to compare character compositions • Edge cases like different lengths should be handled first • Breaking the problem into small steps makes it easy to reason about Takeaway: Sometimes, sorting can reduce a seemingly complex problem into a simple comparison. #DSA #Java #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #Strings
To view or add a comment, sign in
-
-
Day 60 - Remove Duplicates from Sorted List Worked on removing duplicate elements from a sorted linked list. Approach: • Traverse the list once • Compare current node with next node • Skip duplicate nodes by adjusting pointers Time Complexity: O(n) Space Complexity: O(1) #Day60 #LeetCode #Java #LinkedList #CodingPractice #DSA #TechJourney
To view or add a comment, sign in
-
-
💻 Day 35 of #LeetCode Journey 🔥 Solved: 19. Remove Nth Node From End of List Today’s problem was all about mastering Linked Lists and understanding the power of the Two Pointer technique. 🔍 Key Idea: Instead of calculating the length, I used a smart approach with fast and slow pointers. Move the fast pointer n steps ahead Then move both pointers together This helps locate the node to remove in a single pass ⚡ Why this approach? Efficient: O(n) time complexity No extra space required Clean and optimal solution 🧠 What I learned: Using a dummy node simplifies edge cases (like removing the head) Two-pointer technique is very powerful in linked list problems 📌 Problem Link: https://lnkd.in/gxXDR-YV #Java #DataStructures #LinkedList #CodingJourney #100DaysOfCode #LeetCode #ProblemSolving
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