Day 19/30 – Palindrome Linked List 🚀 Problem: Check if a linked list is a palindrome. Approach: 1️⃣ Find middle using slow & fast pointers 2️⃣ Reverse second half 3️⃣ Compare both halves Why this approach? • O(n) time • O(1) space • No extra array Classic pointer manipulation + in-place reversal. #30DaysOfCode #Java #DSA #LinkedList #InterviewPrep
Palindrome Linked List Check in O(n) Time
More Relevant Posts
-
Day 56 - Search a 2D Matrix Approached the problem by leveraging the sorted property of the matrix. Applied binary search over virtual 1D space instead of traversing row-wise. Time Complexity: O(log(m*n)) #Day56 #LeetCode #Java #BinarySearch #Matrix #DSA #CodingPractice #ProblemSolving
To view or add a comment, sign in
-
-
Day 46 - String Compression Used a two pointer approach to group consecutive characters and write compressed results directly into the input array. If a character repeats, its count is converted to digits and appended sequentially. Time Complexity: O(n) #Day46 #LeetCode #Java #Algorithms #TwoPointers #DSA
To view or add a comment, sign in
-
-
Day 45 — LeetCode Progress (Java) Problem: Intersection of Two Arrays Required: Given two integer arrays nums1 and nums2, return an array containing their unique intersection elements. Idea: Use a HashSet to efficiently track elements from the first array and check their presence in the second array. Approach: Create a HashSet to store all elements from nums1. Traverse nums1 and insert each element into the set. Initialize a list to store the intersection result. Iterate through nums2: If an element exists in the set: Add it to the result list. Remove it from the set to avoid duplicates. Convert the result list into an array and return it. Time Complexity: O(n + m) n = length of nums1 m = length of nums2 Space Complexity: O(n) #LeetCode #DSA #Java #HashSet #Arrays #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
𝐐. Why call 𝐓𝐡𝐫𝐞𝐚𝐝.𝐜𝐮𝐫𝐫𝐞𝐧𝐭𝐓𝐡𝐫𝐞𝐚𝐝().𝐢𝐧𝐭𝐞𝐫𝐫𝐮𝐩𝐭() inside a catch block for 𝐈𝐧𝐭𝐞𝐫𝐫𝐮𝐩𝐭𝐞𝐝𝐄𝐱𝐜𝐞𝐩𝐭𝐢𝐨𝐧? 𝐀) To forcefully stop the thread immediately 𝐁) To restore the flag so higher-level code knows the thread was interrupted 𝐂) To throw a new 𝘐𝘯𝘵𝘦𝘳𝘳𝘶𝘱𝘵𝘦𝘥𝘌𝘹𝘤𝘦𝘱𝘵𝘪𝘰𝘯 to the caller Try yourself, if not see answer and explanation in 1st comment. 👀 If you want to understand more about interrupts see 2nd comment. #Java #Multithreading #JavaDeveloper #SoftwareEngineering #CodingInterview
To view or add a comment, sign in
-
Day 24/50 – LeetCode Solved the Reverse String problem using the two-pointer approach. The solution involves swapping characters from both ends of the array and moving inward until the pointers meet. This ensures an in-place reversal with O(1) extra space and O(n) time complexity. A straightforward problem that reinforces fundamental concepts. #LeetCode #50DaysOfCode #Java #DataStructures
To view or add a comment, sign in
-
-
𝗬𝗼𝘂 𝗵𝗮𝘃𝗲 𝗯𝗲𝗲𝗻 𝘂𝘀𝗶𝗻𝗴 𝗕𝗶𝗻𝗮𝗿𝘆 𝗦𝗲𝗮𝗿𝗰𝗵 𝘄𝗿𝗼𝗻𝗴. It is not just for sorted arrays. The real definition — "Eliminate HALF the search space with each decision." That one shift in thinking unlocks 20+ LeetCode problems. Swipe to see the template, live code, and 7 problems you can now solve with one pattern. 👇 Save this. 🔖 #DSA #BinarySearch #Java #LeetCode #CodingInterview #DebugWithPurpose
To view or add a comment, sign in
-
Day 58 – Transpose Matrix Worked on a problem to transform a matrix by flipping it over its main diagonal, effectively converting rows into columns. Key Learnings: Learned to handle dimension changes when rows and columns differ Improved understanding of 2D array traversal and manipulation #DSA #Java #Matrix #Arrays #ProblemSolving #CodingPractice
To view or add a comment, sign in
-
-
Day 10 of #75DaysOfDSA #SolvedTwoSum (Using Two Pointers) 🔹 Approach: Sorting + Two Pointers Sorted the array, then used two pointers (left & right) to find the target sum efficiently. 🔹 Key Idea If sum == target → pair found If sum < target → move left pointer If sum > target → move right pointer 🔹 Why it works Sorting allows us to adjust pointers intelligently instead of checking all pairs. 🔹 Complexity Time: O(n log n) (due to sorting) Space: O(1) 🔹 Takeaway Two pointers is a powerful technique for sorted arrays, reducing brute force from O(n²) to near linear time. #DSA #TwoPointers #Java #CodingChallenge #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
Day 50 – Decode String Worked on decoding encoded strings with patterns like k[encoded_string], including handling nested structures using stacks. Key Learnings: Learned how to use stacks to manage nested patterns effectively Understood how to process numbers, brackets, and characters step by step #DSA #Java #Stack #Strings #ProblemSolving #CodingPractice
To view or add a comment, sign in
-
-
• String & String Constant Pool • Immutability & Memory Management • String Comparison Techniques • Concatenation Methods & Performance Tests • substring(), split(), indexOf() • String vs StringBuffer vs StringBuilder • Immutable Class Design • toString() Method • StringTokenizer (Legacy vs Modern Approach) Understanding how Strings work internally is crucial for writing efficient, optimized, and interview-ready Java code. Strong fundamentals. Clean code. Better performance. #Java #CoreJava #JavaDeveloper #DSA #StringConcepts #Coding #LearningJourney #CodesInTransit #InterviewPreparation #MondayMotivation #RevisitingTheTopics
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