🚀 Day 81/100 – 𝐋𝐨𝐧𝐠𝐞𝐬𝐭 𝐒𝐮𝐛𝐬𝐭𝐫𝐢𝐧𝐠 𝐰𝐢𝐭𝐡 𝐀𝐭 𝐋𝐞𝐚𝐬𝐭 𝐊 𝐑𝐞𝐩𝐞𝐚𝐭𝐢𝐧𝐠 𝐂𝐡𝐚𝐫𝐚𝐜𝐭𝐞𝐫𝐬 Today’s problem was a bit tricky but super interesting — Longest Substring with At Least K Repeating Characters. 🔍 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠: This problem can be efficiently solved using a 𝐃𝐢𝐯𝐢𝐝𝐞 & 𝐂𝐨𝐧𝐪𝐮𝐞𝐫 𝐚𝐩𝐩𝐫𝐨𝐚𝐜𝐡 instead of brute force. 💡 𝐂𝐨𝐫𝐞 𝐈𝐝𝐞𝐚: Count frequency of all characters If any character appears less than k, it cannot be part of the valid substring Split the string at that character and solve recursively ⚡ 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡: Count 𝐟𝐫𝐞𝐪𝐮𝐞𝐧𝐜𝐲 𝐨𝐟 𝐜𝐡𝐚𝐫𝐚𝐜𝐭𝐞𝐫𝐬 Traverse string: If any char frequency < k → split Recursively solve 𝐥𝐞𝐟𝐭 & 𝐫𝐢𝐠𝐡𝐭 parts Return max of both ⏱️ 𝐓𝐢𝐦𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: ~O(n log n) (depends on splits) 📦 𝐒𝐩𝐚𝐜𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: O(n) (recursion stack) #Day81 #100DaysOfCode #Java #DSA #LeetCode #DivideAndConquer #CodingJourney
Longest Substring with At Least K Repeating Characters
More Relevant Posts
-
Solved the Copy List with Random Pointer problem using an in-place approach. Instead of using extra space like HashMap, the solution inserts copied nodes in between original nodes, sets random pointers, and then separates both lists. This keeps the solution efficient in both time and space. Time Complexity: O(n) Space Complexity: O(1) #Java #DSA #LinkedList #LeetCode #Coding
To view or add a comment, sign in
-
-
Day 82 of DSA Journey Solved Isomorphic Strings today! This problem looks simple, but it teaches an important concept — one-to-one mapping between characters. 🔍 What I learned: Each character in one string must map to exactly one character in the other No two characters should map to the same character Consistency across the entire string is key 💡 Approach: Used two HashMaps to track mappings in both directions: s → t t → s This avoids conflicts and ensures correctness. 🧠 Example: "paper" → "title" ✅ "foo" → "bar" ❌ ✨ Key takeaway: Always think about bidirectional mapping when dealing with transformation problems. Small problem, but powerful concept! #DSA #Java #CodingJourney #100DaysOfCode #ProblemSolving
To view or add a comment, sign in
-
-
Day 33/50 🚀 — Valid Palindrome (Two Pointer Approach) Today’s problem was a great mix of string manipulation + two pointers. 🔹 Ignored non-alphanumeric characters 🔹 Handled case-insensitivity 🔹 Compared characters from both ends efficiently Key insight: Instead of preprocessing the string, we can optimize in-place using two pointers, skipping unwanted characters on the go. 💡 This improves both readability and performance. Performance: ⚡ Runtime: 2 ms (99%+) 📦 Memory: Efficient #Day33 #LeetCode #TwoPointers #DSA #Java #CodingJourney #50DaysOfCode #ProblemSolving
To view or add a comment, sign in
-
-
The Two-Pointer streak continues! Today’s LeetCode Problem: Is Subsequence. After using multiple pointers to sort arrays and move zeroes, I applied the exact same pattern to string manipulation today. The challenge was figuring out if a shorter string (s) is a valid subsequence of a longer string (t) without disturbing the relative order of the characters. Instead of generating all possible subsequences (which would be a massive O(2ⁿ) performance drain), the Two-Pointer approach solves this beautifully in a single pass. Knocking this out in O(n) time and O(1) space is another great reminder of how incredibly versatile this algorithmic pattern is for both arrays and strings. #DSA #Java #LeetCode #IsSebsequenceProblem
To view or add a comment, sign in
-
-
🚀 Day 26/100 Days of #CodeChallenge Today’s problem: Isomorphic Strings (Leetcode 205) This problem helped me understand how to map characters between two strings while maintaining consistency and order. 💡 Key Concept: Two strings are isomorphic if characters in one string can be replaced to get the other string — with: ✔️ One-to-one mapping ✔️ No two characters mapping to the same character ✔️ Order preserved 🧠 What I Learned: How to use mapping (arrays/hashmaps) efficiently Importance of bidirectional checking Handling edge cases like unequal lengths ⚡ Approach: Compare lengths first Track character mappings using arrays Ensure consistency in both directions ⏱️ Complexity Analysis: Time Complexity: O(n) → We traverse the strings once Space Complexity: O(1) → Fixed-size arrays (256 characters) ✅ Successfully solved and understood the logic! Every day is a step closer to mastering problem-solving 💪 #Day26 #100DaysOfCode #Java #DSA #LeetCode #CodingJourney #ProblemSolving #TechLearning
To view or add a comment, sign in
-
-
Day 35 of Consistency 💻🔥 Solved Longest Substring Without Repeating Characters — a classic sliding window problem that really tests optimization skills. ✨ Key Takeaways: Mastered the sliding window technique Used HashMap for efficient lookup Improved understanding of two-pointer approach ⚡ Performance: Runtime: 5 ms Beat: 87%+ submissions Every day is about getting sharper, not just solving problems. #LeetCode #DataStructures #Algorithms #CodingJourney #Consistency #Java #ProblemSolving
To view or add a comment, sign in
-
-
🚀100 Days of Code Day-26 LeetCode Practice – Remove Duplicates from Sorted Array Solved a classic problem using the Two Pointer Technique 💡 📌 Problem: Given a sorted array, remove duplicates in-place and return the number of unique elements. 🔍 Key Idea: Since the array is sorted, duplicates are adjacent. Using two pointers helps efficiently overwrite duplicates without extra space. ⚡ Complexity: Time → O(n) Space → O(1) 💻 Clean and optimized approach makes this problem a great example of in-place array manipulation! #LeetCode #Java #DataStructures #CodingPractice #ProblemSolving #100DaysOfCode
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 44 of LeetCode Problem Solved! 🔧 🌟205. Isomorphic Strings🌟 Task : • Given two strings s and t, determine if they are isomorphic. • Two strings s and t are isomorphic if the characters in s can be replaced to get t. • All occurrences of a character must be replaced with another character while preserving the order of characters. • No two characters may map to the same character, but a character may map to itself. Example 1: Input: s = "egg", t = "add" Output: true Explanation: The strings s and t can be made identical by: Mapping 'e' to 'a'. Mapping 'g' to 'd'. Example 2: Input: s = "f11", t = "b23" Output: false Explanation: The strings s and t can not be made identical as '1' needs to be mapped to both '2' and '3'. #LeetCode #Java #DSA #ProblemSolving #Consistency #100DaysOfChallenge #CodingJourney #KeepGrowing
To view or add a comment, sign in
-
-
Day 22 of #50DaysLeetCode Challenge 🚀 Today I solved the “Remove Element” problem using Java. 🔹 Problem: Given an array and a value, remove all occurrences of that value in-place and return the number of remaining elements. 🔹 Approach: Used the two-pointer technique. One pointer iterates through the array, while the other keeps track of where to place elements that are not equal to the given value. 🔹 Key Learning: In-place array problems often rely on pointer manipulation instead of extra space. 🔹 Time Complexity: O(n) 🔹 Example: Input: nums = [3,2,2,3], val = 3 Output: 2 (array becomes [2,2,...]) Simple problem, but important for mastering array manipulation techniques. #Day22 #LeetCode #Java #DSA #Arrays #TwoPointers #CodingJourney #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