⚡ 𝗗𝗮𝘆 𝟲𝟲 𝗼𝗳 𝗠𝘆 𝟭𝟬𝟬 𝗗𝗮𝘆𝘀 𝗼𝗳 𝗗𝗦𝗔 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲! 𝘛𝘰𝘥𝘢𝘺’𝘴 𝘧𝘰𝘤𝘶𝘴 𝘸𝘢𝘴 𝘰𝘯 𝘢𝘱𝘱𝘭𝘺𝘪𝘯𝘨 𝘵𝘳𝘢𝘷𝘦𝘳𝘴𝘢𝘭 𝘭𝘰𝘨𝘪𝘤 𝘵𝘰 𝘴𝘰𝘭𝘷𝘦 𝘢 𝘳𝘦𝘢𝘭 𝘶𝘴𝘦-𝘤𝘢𝘴𝘦 𝘱𝘳𝘰𝘣𝘭𝘦𝘮 𝘪𝘯 𝘚𝘪𝘯𝘨𝘭𝘺 𝙇𝙞𝙣𝙠𝙚𝙙 𝙇𝙞𝙨𝙩𝙨. Searching an element may look simple, but it reinforces how data is accessed sequentially in linked structures. 📌 Problem Solved: 1️⃣ Search an Element in a Singly Linked List ✨ Key Learnings: 🔹 Unlike arrays, linked lists 𝗱𝗼𝗻’𝘁 𝘀𝘂𝗽𝗽𝗼𝗿𝘁 𝗱𝗶𝗿𝗲𝗰𝘁 𝗶𝗻𝗱𝗲𝘅𝗶𝗻𝗴, so searching requires full traversal. 🔹 Each node is checked one by one using the next reference until the element is found or the list ends. 🔹 This problem strengthens understanding of 𝗹𝗶𝗻𝗲𝗮𝗿 𝘁𝗶𝗺𝗲 𝗰𝗼𝗺𝗽𝗹𝗲𝘅𝗶𝘁𝘆 𝗢(𝗻) in linked lists. Day 66 completed — mastering traversal step by step! 💪🔥 #100DaysOfCode #DSA #Java #LinkedList #DataStructures #ProblemSolving #LogicBuilding #InterviewPreparation #LearningInPublic #Developers
Day 66: Solving Linked List Search in Java
More Relevant Posts
-
𝐃𝐚𝐲 𝟑𝟐/𝟑𝟔𝟓 🚀 📌 𝐋𝐞𝐞𝐭𝐂𝐨𝐝𝐞 𝐏𝐎𝐓𝐃: 𝐂𝐨𝐮𝐧𝐭 𝐁𝐢𝐧𝐚𝐫𝐲 𝐒𝐮𝐛𝐬𝐭𝐫𝐢𝐧𝐠𝐬 Continuing my 𝟑𝟔𝟓 𝐃𝐚𝐲𝐬 𝐨𝐟 𝐂𝐨𝐝𝐞 journey with a focus on 𝐩𝐫𝐨𝐛𝐥𝐞𝐦-𝐬𝐨𝐥𝐯𝐢𝐧𝐠, 𝐃𝐒𝐀, 𝐚𝐧𝐝 𝐜𝐨𝐧𝐬𝐢𝐬𝐭𝐞𝐧𝐜𝐲. Today’s challenge focused on grouping logic and pattern counting in strings. 💪 🔍 𝐀𝐥𝐠𝐨𝐫𝐢𝐭𝐡𝐦 𝐮𝐬𝐞𝐝: Single-pass grouping technique that tracks the lengths of consecutive character blocks. ⏱ 𝐓𝐢𝐦𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: 𝐎(𝐧) 🧠 𝐒𝐩𝐚𝐜𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: 𝐎(𝟏) 📈 𝐊𝐞𝐲 𝐭𝐚𝐤𝐞𝐚𝐰𝐚𝐲: By comparing the sizes of adjacent character groups, we can efficiently count valid binary substrings without generating all substrings. #LeetCode #LeetCodeDaily #365DaysOfCode #DSA #Java #Strings #ProblemSolving #LearningInPublic 👨💻 🔗 Problem link in comments 👇
To view or add a comment, sign in
-
-
🚀 Day 9 — LeetCode Progress (Java) 🔹 Next Greater Element I → Built a mapping using HashMap by scanning the second array and identifying the next greater value for each element, then used it to construct the result efficiently without repeated searches. ━━━━━━━━━━━━━━━━━━━━ Today’s focus was on improving array traversal logic and understanding how mapping relationships between elements can simplify future lookups. Instead of brute force comparisons for every query, pre-processing the array helped reduce unnecessary checks and made the solution cleaner. 💭 Takeaways: • Precomputing relationships using hashing can drastically reduce complexity. • Writing readable loops is just as important as getting the correct answer. • Small optimizations in logic structure make solutions easier to scale later. Consistency continues. One step closer to stronger fundamentals. 🔥 #LeetCode #DSA #Java #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 9 of #100DaysOfDSA (Java) Today I focused on Arrays — the foundation of Data Structures. Covered: Array declaration & creation Indexing and traversal Linear Search Binary Search Basic array operations Big learning today 👇 Arrays may look simple, but they teach: Memory structure Time complexity thinking How search efficiency changes from O(n) to O(log n) Understanding the difference between Linear Search and Binary Search really helped me see how optimization works in real problems. Small steps, strong foundation. Day 9 ✅ Consistency is becoming a habit. #DSA #Java #100DaysOfCode #Arrays #ProblemSolving #CodingJourney #FutureDeveloper #LearningInPublic
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟐𝟔/𝟑𝟔𝟓 🚀 📌 𝐋𝐞𝐞𝐭𝐂𝐨𝐝𝐞 𝐏𝐎𝐓𝐃: 𝐋𝐨𝐧𝐠𝐞𝐬𝐭 𝐁𝐚𝐥𝐚𝐧𝐜𝐞𝐝 𝐒𝐮𝐛𝐬𝐭𝐫𝐢𝐧𝐠 𝐈𝐈 Continuing my 𝟑𝟔𝟓 𝐃𝐚𝐲𝐬 𝐨𝐟 𝐂𝐨𝐝𝐞 journey with a focus on 𝐩𝐫𝐨𝐛𝐥𝐞𝐦-𝐬𝐨𝐥𝐯𝐢𝐧𝐠, 𝐃𝐒𝐀, 𝐚𝐧𝐝 𝐜𝐨𝐧𝐬𝐢𝐬𝐭𝐞𝐧𝐜𝐲. Today’s challenge required optimizing substring balance detection using prefix-state tracking. 💪 🔍 𝐀𝐥𝐠𝐨𝐫𝐢𝐭𝐡𝐦 𝐮𝐬𝐞𝐝: Prefix-difference technique with state compression and a HashMap to track balanced character distributions efficiently. ⏱ 𝐓𝐢𝐦𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: 𝐎(𝐧) 🧠 𝐒𝐩𝐚𝐜𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: 𝐎(𝐧) 📈 𝐊𝐞𝐲 𝐭𝐚𝐤𝐞𝐚𝐰𝐚𝐲: Balanced substring problems can often be reduced to tracking prefix differences and identifying repeated states. #LeetCode #LeetCodeDaily #365DaysOfCode #DSA #Java #Strings #HashMap #ProblemSolving #LearningInPublic 👨💻 🔗 Problem link in comments 👇
To view or add a comment, sign in
-
-
Day - 59 Subsets The problem - Given array of unique integers, return all possible subsets (power set). Solution must not contain duplicate subsets. Example : nums = [1,2,3] → [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] Brute Force - Generate all combinations iteratively, still exponential, but less elegant than recursion. Approach Used - •) Call createSubset(nums, 0, res, subset). •) Base case, if index == nums.length, add current subset to result. •) Recursive First case, include nums[index], add to subset, recurse with index+1, backtrack (remove). •) Recursive Second case, exclude nums[index]: recurse with index+1 (don't add). Complexity - Time - O(n × 2^n),each element has 2 choices. Space - O(n), recursion depth. Note - For each element, make two choices, include it or exclude it. Recursively build all combinations #DSA #Java #SoftwareEngineering #InterviewPrep #LearnToCode #CodeDaily #ProblemSolving
To view or add a comment, sign in
-
-
Continued with nested if-else today. At first, it felt like just putting one if inside another. But while writing it, I realized structure matters as much as logic. int marks = sc.nextInt(); if (marks >= 33) { if (marks >= 80) { System.out.println("Pass with distinction"); } System.out.println("Pass"); } else { System.out.println("Fail"); } This worked, but it made me think about two things: - Nested conditions can express dependency clearly - But they can also hurt readability if overused The logic is correct, but how it’s written decides how easy it is to understand later. Continuing with the rest of the conditionals module today. #Java #Conditionals #LearningInPublic #Beginner #DSA
To view or add a comment, sign in
-
🔥Day 91 of #100DaysOfLeetCode Problem: 1653. Minimum Deletions to Make String Balanced Difficulty: Medium Key Insight: A balanced string must have all 'a's before all 'b's. Any 'b' before an 'a' creates a violation. Approach: Preprocess the string using: - prefixB[i]: number of 'b's strictly before index i - suffixA[i]: number of 'a's strictly after index i For every index i, treat it as a split point and compute: deletions = prefixB[i] + suffixA[i] The minimum over all splits is the answer. Time Complexity: O(n) Space Complexity: O(n) #LeetCode #Java #ProblemSolving #CodingChallenge #100DaysOfCode #DSA #LearningEveryday
To view or add a comment, sign in
-
-
Arrays are fixed. Real applications aren’t. That’s why Java introduced the 𝗖𝗼𝗹𝗹𝗲𝗰𝘁𝗶𝗼𝗻𝘀 𝗙𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸. Instead of managing size manually, you use dynamic data structures like: • 𝐀𝐫𝐫𝐚𝐲𝐋𝐢𝐬𝐭 • 𝐋𝐢𝐧𝐤𝐞𝐝𝐋𝐢𝐬𝐭 • 𝐇𝐚𝐬𝐡𝐒𝐞𝐭 • 𝐇𝐚𝐬𝐡𝐌𝐚𝐩 Example: List<String> names = new ArrayList<>(); names.add("Alice"); names.add("Bob"); Unlike arrays: • Collections grow dynamically • Provide built-in methods • Reduce manual memory handling But collections are not interchangeable. Choosing the wrong one affects: • Performance • Memory usage • Readability For example: • ArrayList → fast random access • LinkedList → efficient insert/delete • HashSet → unique elements • HashMap → key-value storage Today was about: Understanding why collections exist When to use List vs Set vs Map Writing scalable data logic Good developers don’t just store data. They choose the right structure for it. #Java #Collections #DataStructures #SoftwareEngineering #Programming #LearningInPublic
To view or add a comment, sign in
-
-
𝗗𝗮𝘆 𝟳/𝟮𝟬 — 𝗟𝗲𝗲𝘁𝗖𝗼𝗱𝗲 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲🎯 Solved Longest Valid Parentheses ➤ Problem: Given a string of ‘(’ and ‘)’, determine the length of the longest well-formed (valid) parentheses substring. ➤ Approach: Used a clean and structured stack-based technique to identify valid boundaries efficiently. • Initialize the stack with -1 as the base index. • Push every '(' index onto the stack. • On encountering ')', pop to attempt a match. • If the stack becomes empty, push the current index as the new starting point. • Otherwise, compute the valid substring length using currentIndex − stackTop. Continuously update the maximum length. This ensures each character is processed in a single pass, maintaining optimal efficiency. #LeetCode #Java #DSA #TwoPointers #ArrayManipulation #ProblemSolving #20DaysChallenge #Consistency
To view or add a comment, sign in
-
-
Day 23 — LeetCode Progress (Java) Problem: Search in Rotated Sorted Array Required: Given a sorted array that has been rotated at some pivot unknown beforehand, search for a target value in O(log n) time. If found, return its index. Otherwise, return -1. Brute force O(n) is not acceptable — the constraint forces binary search thinking. Idea: Even though the array is rotated, at least one half of the array (left or right) is always sorted. At every step of binary search: Either left → mid is sorted Or mid → right is sorted If we can detect which half is sorted, we can check whether the target lies inside that sorted range and eliminate the other half. The rotation doesn’t break ordering — it just splits it into two sorted segments. Approach: Initialize left = 0, right = n - 1 While left ≤ right: Compute mid If nums[mid] == target → return mid Check if left half is sorted (nums[left] ≤ nums[mid]) • If target lies within that range → move right • Else → move left Otherwise right half must be sorted • If target lies within that range → move left • Else → move right If loop ends → return -1 Time Complexity: O(log n) Space Complexity: O(1) Core Insight: Binary search isn’t about sorted arrays. It’s about partially ordered structure. If you can detect order in fragments, you can still cut the search space in half. #LeetCode #DSA #Java #BinarySearch #CodingJourney
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