Day 7 | Problem 1 – Sentence Similarity III (LeetCode 1813) Solved Problem 1 by determining whether two sentences can become equal by inserting a group of words at exactly one position. Approach: • Split both sentences into word arrays using split(" ") • Ensured the smaller sentence is used as the base for comparison • Matched common words from the beginning (prefix match) • Matched common words from the end (suffix match) • Checked if prefix + suffix matches covered all words of the smaller sentence This problem strengthened my understanding of: • Two-pointer technique • String manipulation • Logical comparison of sequences Continuing my 15-Day 50+ String DSA Challenge 🚀 #DSA #Java #StringProblems #LeetCode #LearningInPublic #CodingJourney
LeetCode 1813: Sentence Similarity III Solution
More Relevant Posts
-
Day: 53/365 📌 LeetCode POTD: Concatenation of Consecutive Binary Numbers Medium Key takeaways/Learnings from this problem: 1. This problem nicely mixes math + bit manipulation, especially understanding how many bits each number contributes. 2. Instead of literally concatenating strings, shifting the current result left by the bit-length is way more efficient. 3. It reinforces the idea that log2 helps you find bit length quickly for each number. 4. Big takeaway: always think in terms of binary operations when the problem screams “binary” — strings are usually a trap here. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
To view or add a comment, sign in
-
-
Strings look simple until edge cases show up 👀 Day 8 / #100DaysOfCode 🚀 Solved: Valid Palindrome (LeetCode 125) 🔹 Approach: Used the two-pointer technique starting from both ends. Ignored non-alphanumeric characters and compared characters after converting the string to lowercase. Time Complexity: O(n) Space Complexity: O(1) ✔ Practiced string traversal with pointers ✔ Handled real-world edge cases (spaces, symbols, cases) ✔ Avoided extra space by working in-place 💡 Takeaway: Clean pointer logic often beats preprocessing with extra data structures. Building strong fundamentals in Java, one problem at a time. #LearnInPublic #100DaysOfCode #DSA #Java #Strings #ProblemSolving #SoftwareEngineer #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 73/100 of my DSA Journey ✅ Problem solved today: LeetCode 1461 – Check If a String Contains All Binary Codes of Size K 🧠 What I focused on: Using a HashSet to store all substrings of length k Sliding window technique to generate substrings efficiently Understanding why we only need to check if the number of unique substrings equals 2^k Handling edge cases when string length is smaller than k This problem nicely combined strings + sliding window + hashing logic. 📌 Key takeaway: Sometimes the solution is just counting unique patterns efficiently. 📈 Day 73 done. Consistency continues. #LeetCode #DSA #SlidingWindow #Strings #Hashing #Java #ProblemSolving #Consistency #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
-
Day 25 of #100DaysOfLeetCode 💻✅ Solved #167. Two Sum II – Input Array Is Sorted on LeetCode using Java. Approach: • Used Two Pointer technique since the array is already sorted • Initialized one pointer at the beginning and one at the end • Calculated the sum of both elements • If sum < target, moved left pointer forward • If sum > target, moved right pointer backward • Returned 1-based indices as required in the problem Performance: ✓ Runtime: 1 ms (Efficient with O(n) time complexity) ✓ Memory: Constant extra space (O(1)) Key Learning: ✓ Understood when to apply Two Pointer technique instead of HashMap ✓ Improved ability to optimize space complexity ✓ Strengthened pattern recognition for sorted array problems Learning one problem every single day 🚀 #Java #LeetCode #DSA #TwoPointers #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🔥 Day 513 of #750DaysofCode 🔥 LeetCode 1461 | Check If a String Contains All Binary Codes of Size K Today’s problem was a really interesting mix of strings + hashing + sliding window + bit manipulation. 🧠 Problem Summary: Given a binary string s and an integer k, return true if every possible binary code of length k exists as a substring of s. For example: Input: s = "00110110", k = 2 All possible binary codes of size 2 → "00", "01", "10", "11" Since all exist → ✅ true 💡 Key Insight For length k, total possible binary codes = 2^k So instead of generating all binary codes explicitly, we: Slide a window of size k across the string Store each substring in a HashSet If set.size() == 2^k, we return true ⚡ Optimized Thinking Since: k <= 20 2^20 = 1,048,576 We can also use: Rolling hash Bitmask technique Integer encoding instead of substring creation 🎯 What I Learned Today ✔ Instead of generating all combinations, track what appears ✔ Bitmasking can optimize substring problems ✔ Sliding window + hashing is powerful for pattern coverage problems ✔ Always check constraints before choosing brute force Consistency > Motivation 💪 Onwards to Day 514 🚀 #750DaysOfCode #LeetCode #Java #DSA #CodingJourney #BitManipulation #SlidingWindow
To view or add a comment, sign in
-
-
100 Days of Coding Challenge – Day 16 📌 Problem: Roman to Integer 💻 Language: Java 🧠 Concept Used: HashMap + Conditional Traversal 🔍 Platform: LeetCode Today’s challenge was converting a Roman numeral into its integer representation. Approach: ✔ Stored Roman symbols and values in a HashMap ✔ Traversed the string from left to right ✔ If the current value is smaller than the next → subtract ✔ Otherwise → add Time Complexity: O(n) Space Complexity: O(1) 🔗 Problem Link: https://lnkd.in/g2YTaPrG 🔗 Code: https://lnkd.in/g7e_Y7V7 #100DaysOfCode #Day16 #Java #DSA #LeetCode #Strings #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Leetcode Problem || Sort Integers by Number of 1 Bits (1356)🚀 Today I worked on a problem where we sort integers based on: 1️⃣ Number of set bits in binary representation 2️⃣ If equal, sort by numerical value 💡 Learned: How comparator chaining works Importance of object boxing in Java sorting Clean way to handle multi-level sorting #Java #DSA #LeetCode #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 1/100 – LeetCode Challenge 🚀 Problem: #867 Transpose Matrix Difficulty: Easy Language: Java Approach: Nested Loop with Index Swapping Time Complexity: O(m × n) Space Complexity: O(m × n) 🔍 Key Insight: The transpose of a matrix swaps rows and columns. If original matrix is m × n, the result will be n × m. Careful index handling is important to avoid dimension errors. 🧠 Solution Brief: Created a new matrix with reversed dimensions. Traversed the original matrix using nested loops. Assigned result[j][i] = matrix[i][j] to swap row and column indices. Returned the transposed matrix. this solution is basicaly bruteforce approach 📌 What I Learned: Even simple matrix problems improve understanding of 2D array traversal and index manipulation. Consistency starts today — 99 more days to go 💪 #LeetCode #Day1 #100DaysOfCode #Java #DSA #ProblemSolving #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
-
Day 23/100 – DSA Challenge 🚀 📌 Problem: Longest Repeating Character Replacement 📌 Pattern: Advanced Sliding Window 📌 Language: Java Today I worked on strengthening my sliding window understanding. The goal was to find the longest substring that can be converted into a single repeating character after at most k replacements. Key idea: Maintain a window using two pointers Track character frequency inside the window Keep track of the highest frequency character (maxFreq) If (windowSize - maxFreq) > k, shrink the window This problem taught me: How to control window validity mathematically Why we don’t decrease maxFreq when shrinking How small mistakes (like double increment or wrong indexing) can break logic ⏱ Time Complexity: O(n) 📦 Space Complexity: O(1) #100DaysOfCode #DSA #Java #LeetCode #SlidingWindow #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 25 of Solving DSA Problems 🧠 Pattern Learned: Prefix Sum + HashMap Today I learned one of the most powerful patterns for solving subarray problems efficiently. 💡 Key Idea: If the difference between two prefix sums equals k, then the subarray between them has sum k. So while traversing the array: keep adding to prefix sum check if (currentSum − k) was seen before if yes → we found a valid subarray ⚡ This avoids checking all subarrays and reduces complexity from O(n²) → O(n). ⏱ Complexity: Time → O(n) Space → O(n) 🔥 Lesson: Prefix sum turns a range problem into a lookup problem using hashing — and that’s a game-changer. Consistency builds clarity 📈 #DSA #Java #ProblemSolving #CodingJourney #LearningInPublic
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