Day 9 of #30DaysOfCode | LeetCode Problem 3. Longest Substring Without Repeating Characters Implemented an optimized Sliding Window approach to find the length of the longest substring without repeating characters. By maintaining a dynamic window using two pointers and a hash set, the algorithm achieves O(n) time complexity while efficiently managing unique character sequences. #Python #LeetCode #CodingChallenge #ProblemSolving #DataStructures #Algorithms #DSA
Optimized Sliding Window for Longest Substring Without Repeating Characters
More Relevant Posts
-
Day 6 of #100DaysOfLeetCode Problem: 3. Longest Substring Without Repeating Characters Category: Strings / Sliding Window Today’s problem was about finding the length of the longest substring without any repeating characters — a classic question that tests understanding of window management and string traversal. 🧠 Key Learnings: Used a sliding window technique to dynamically adjust the current substring when a duplicate character was found. Tracked characters in the current substring and shifted the start position upon repetition. Focused on maintaining both time efficiency and substring accuracy by managing indices smartly. 🎯 Takeaway: Sliding window techniques are powerful for handling substring and subarray problems efficiently — balance between expanding and shrinking the window is the key. #LeetCode #100DaysOfCode #ProblemSolving #CodingJourney #Strings #SlidingWindow #Python #AIEngineer #Consistency
To view or add a comment, sign in
-
-
Day 69: Scramble String (Memoization) 🧠 I'm tackling a challenging Hard DP problem on Day 69 of #100DaysOfCode: "Scramble String." The goal is to see if one string can be made from another by recursively splitting and swapping substrings. My solution uses Memoization (Top-Down DP) to avoid re-solving the same subproblems. The core logic recursively checks two possibilities for every split: Swap or No Swap. This optimization allows the complex search to complete efficiently. #Python #DSA #Algorithms #DynamicProgramming #Memoization #100DaysOfCode #HardChallenge
To view or add a comment, sign in
-
-
🚀 LeetCode #3461 – Check If Digits Are Equal in String After Operations I Today’s challenge was all about pattern transformation using modulo logic! 🔢 We repeatedly take each pair of consecutive digits, find their sum modulo 10, and form a new sequence, until only two digits remain. If both digits are the same, return True; otherwise, return False. ✨ It’s a neat way to test your understanding of string manipulation, loops, and modular arithmetic. 📊 Complexity: Time – O(n²) Space – O(n) Sometimes even the simplest looking problems hide cool math logic behind them 😄 Have you tried this one yet? What was your approach? 👇 #LeetCode #Python #CodingChallenge #ProblemSolving #LogicBuilding #100DaysOfCode #DSA
To view or add a comment, sign in
-
-
Day 11 of #100DaysOfLeetCode Problem: 14. Longest Common Prefix Category: Strings / Comparison / Iteration Today’s challenge focused on finding the longest common prefix among an array of strings. It’s a great problem that improves your understanding of string traversal, comparison, and boundary conditions. 🧠 Key Learnings: Iterated character by character through the first string and compared it with all other strings. Carefully handled edge cases where strings had different lengths or no common prefix. Reinforced the concept of early termination when a mismatch is found — improving efficiency. Strengthened skills in iterative string comparison and control flow logic. 🎯 Takeaway: Small details like string length and early exit conditions make a big difference in optimizing even the simplest problems. #LeetCode #100DaysOfCode #ProblemSolving #CodingJourney #Strings #Python #AIEngineer #Consistency
To view or add a comment, sign in
-
-
Day 41 of #180DaysOfCode Today, I leveled up the 𝗿𝗼𝘁𝗮𝘁𝗲𝗱 𝘀𝗼𝗿𝘁𝗲𝗱 𝗮𝗿𝗿𝗮𝘆 𝗽𝗿𝗼𝗯𝗹𝗲𝗺: 𝗦𝗲𝗮𝗿𝗰𝗵 𝘄𝗶𝘁𝗵 𝗗𝘂𝗽𝗹𝗶𝗰𝗮𝘁𝗲𝘀! 🔍 When the array contains duplicates, the previous approach needed a tweak. If nums[low] == nums[mid] == nums[high], we can't decide which side is sorted. The solution? Trim duplicates by moving low and high inward, then proceed with the standard rotated search logic. This ensures we still achieve O(log n) performance in most cases, though it can degrade to O(n) with many duplicates. A subtle but important edge case that makes binary search even more interesting! #Python #Algorithms #BinarySearch #RotatedArray #Duplicates #Coding
To view or add a comment, sign in
-
-
🚀 Problem: Given an unsorted array of integers, find the length of the longest consecutive sequence — and do it in O(n) time. 💡 Challenge: Most solutions use sorting (O(n log n)), but the goal is linear time complexity. 🧠 Solution: I optimized the approach using a HashSet (Set in Python) — which allows O(1) lookups — and only starts counting when a number is the beginning of a sequence. This ensures every number is visited once. ✅ Result: Efficient O(n) solution with 0ms runtime on LeetCode. #Python #LeetCode #ProblemSolving #CodingJourney #DSA #Algorithms #DeveloperMindset
To view or add a comment, sign in
-
-
🚀 Day 74 of #100DaysOfDSA 🚀 Solved LeetCode 1901 — Find a Peak Element II 🔹 Problem: Find a peak element in a 2D grid — a cell strictly greater than its four neighbors. 🔹 Approach: Binary Search on Columns Perform binary search on the columns. For each middle column, find the maximum element in that column. Compare it with its left and right neighbors: If it's greater than both → it's a peak. Else, move toward the side with the larger neighbor. ✨ Key Insight: Even in 2D grids, binary search can efficiently locate a peak using greedy direction decisions per column. #LeetCode #DSA #BinarySearch #Matrix #Python #ProblemSolving #100DaysOfCode #CodingJourney 🚀
To view or add a comment, sign in
-
-
#Day20 #100DaysOfCode 🧩 Problem: Given a matrix where each row and column is sorted in increasing order, determine whether a given element x exists in the matrix. 💡 Approach: Instead of searching every element, I used an optimized O(n + m) approach — starting from the top-right corner and moving left or down based on comparisons. #100DaysOfCode #Day20 #Python #CodingChallenge #DataStructures #Algorithms #Matrix #SearchAlgorithm #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