🚀 𝗗𝗮𝘆 - 51/60 Problem: URLify a Given String 🔍 Learned: Replaced all spaces in the string with "%20" to make it URL-friendly. This can be done using string traversal or built-in methods. 😅 Struggles: Initially overthought the problem expecting complex logic, but realized it’s just about handling characters efficiently. 🧠 Key Learning: Simple problems test clarity, not complexity. Can use replace() for clean code, or manually build using StringBuilder for better control. Important to maintain O(n) time complexity. 📦 Concepts Used: #Strings #StringBuilder #BasicLogic #TimeComplexity #DSA Not every problem needs complexity—sometimes simplicity is the real skill. 🚀 #Java #CodingJourney #ProblemSolving #DSA
Girinandini S’ Post
More Relevant Posts
-
🚀 𝗗𝗮𝘆 - 57/60 Problem: Reverse Each Word in a String 🔍 Learned: Reversed each word individually while keeping the word order same. Handled spaces carefully to ensure no extra spaces and only single space separation in the final output. 😅 Struggles: The tricky part was dealing with multiple spaces and leading/trailing spaces. Direct splitting sometimes leaves empty strings, so needed proper handling. 🧠 Key Learning: Split string based on spaces and ignore empty words. Reverse each word using StringBuilder or manual logic. Reconstruct the string with single spaces only. 📦 Concepts Used: #Strings #StringBuilder #Split #EdgeCases #DSA Not just reversing—handling spaces correctly is what makes the solution clean. 🚀 #Java #CodingJourney #ProblemSolving #DSA
To view or add a comment, sign in
-
-
LeetCode — Problem 11 | Day 2 💡 Problem: Container With Most Water Given an array of heights, find two lines that together form a container which holds the maximum water. 🧠 My Approach: - Used two pointers (start & end) - Calculated area using "min(height) * width" - Moved the pointer with smaller height to maximize area - Repeated until pointers meet This problem gave a good understanding of: ✔️ Two Pointer Technique ✔️ Optimizing from brute force to O(n) ✔️ Logical thinking in arrays #LeetCode #DSA #Java #CodingJourney
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟕𝟔/𝟑𝟔𝟓 🚀 📌 𝐋𝐞𝐞𝐭𝐂𝐨𝐝𝐞 𝐏𝐎𝐓𝐃: 𝐃𝐞𝐜𝐨𝐝𝐞 𝐭𝐡𝐞 𝐒𝐥𝐚𝐧𝐭𝐞𝐝 𝐂𝐢𝐩𝐡𝐞𝐫𝐭𝐞𝐱𝐭 Continuing my 𝟑𝟔𝟓 𝐃𝐚𝐲𝐬 𝐨𝐟 𝐂𝐨𝐝𝐞 journey with a focus on 𝐩𝐫𝐨𝐛𝐥𝐞𝐦-𝐬𝐨𝐥𝐯𝐢𝐧𝐠, 𝐃𝐒𝐀, 𝐚𝐧𝐝 𝐜𝐨𝐧𝐬𝐢𝐬𝐭𝐞𝐧𝐜𝐲. 💪 🔎 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡: Treat the encoded string as a matrix with given rows. Traverse diagonally starting from each column of the first row. Append characters while moving diagonally (down-right). Trim trailing spaces from the result. 🔍 𝐀𝐥𝐠𝐨𝐫𝐢𝐭𝐡𝐦 𝐮𝐬𝐞𝐝: Matrix simulation with diagonal traversal. ⏱ 𝐓𝐢𝐦𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: 𝐎(𝐧) 🧠 𝐒𝐩𝐚𝐜𝐞 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲: 𝐎(𝐧) 📈 𝐊𝐞𝐲 𝐭𝐚𝐤𝐞𝐚𝐰𝐚𝐲: Many string problems can be visualized as matrix traversals — changing perspective simplifies the solution. #LeetCode #LeetCodeDaily #365DaysOfCode #DSA #Java #Strings #Matrix #Simulation #ProblemSolving #LearningInPublic 👨💻 🔗 Problem link in comments 👇
To view or add a comment, sign in
-
-
Some subarray counting problems become much easier when we transform them into “at most” problems. 🚀 Day 101/365 — DSA Challenge Solved: Binary Subarrays With Sum Problem idea: We need to count the number of subarrays whose sum equals a given goal in a binary array. Efficient approach: Instead of directly counting subarrays with exact sum, we use a trick: subarrays with sum = goal = subarrays with sum ≤ goal − subarrays with sum ≤ (goal − 1) Steps: 1. Create a helper function to count subarrays with sum at most k 2. Use a sliding window to maintain a valid window where sum ≤ k 3. Add the number of valid subarrays ending at each index 4. Subtract results to get the exact count for the goal This converts the problem into an efficient sliding window solution. ⏱ Time: O(n) 📦 Space: O(1) Day 101/365 complete. 💻 264 days to go. Code: https://lnkd.in/dad5sZfu #DSA #Java #SlidingWindow #LeetCode #LearningInPublic
To view or add a comment, sign in
-
-
“Most people try to overcomplicate this one… but the simplest approach wins.” Day 69 — LeetCode Progress Problem: Height Checker Required: Given an array of student heights, return the number of indices where the heights are not in the expected non-decreasing order. Idea: If we sort the array, we get the expected order. Now just compare the original array with the sorted version — mismatches are the answer. Approach: Create a copy of the original array Sort the copied array Traverse both arrays: Compare elements at each index If they differ → increment count Return the count Time Complexity: O(n log n) Space Complexity: O(n) #LeetCode #DSA #Java #Arrays #Sorting #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟕𝟔 – 𝐃𝐒𝐀 𝐉𝐨𝐮𝐫𝐧𝐞𝐲 | 𝐀𝐫𝐫𝐚𝐲𝐬 🚀 Today’s problem focused on summarizing continuous ranges in a sorted array. 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐒𝐨𝐥𝐯𝐞𝐝 • Summary Ranges 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡 – 𝐓𝐰𝐨 𝐏𝐨𝐢𝐧𝐭𝐞𝐫𝐬 • Iterated through the array • Marked the start of a range • Expanded while elements are consecutive Logic: • If only one element → add as single number • If multiple → format as "start->end" • Moved pointer to next new range 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠𝐬 • Two-pointer technique simplifies range problems • Consecutive patterns are common in arrays • Formatting output is part of problem-solving • Simple logic can still be interview-relevant 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲 • Time: O(n) • Space: O(1) (excluding output) 𝐓𝐚𝐤𝐞𝐚𝐰𝐚𝐲 Not all problems are complex — some test how clearly you can identify patterns. 76 days consistent 🚀 On to Day 77. 🔗 Problem Link:https://lnkd.in/dXq9tU58 #DSA #Arrays #TwoPointers #LeetCode #Java #ProblemSolving #DailyCoding #LearningInPublic #SoftwareDeveloper
To view or add a comment, sign in
-
-
🚀 #100DaysOfCode | Day 49 🔍 Solved: Largest Number Today I worked on an interesting problem where the goal was to arrange numbers such that they form the largest possible number. 💡 Key Insight: Instead of normal sorting, we compare numbers based on their string combinations (like "ab" vs "ba"). 📌 Approach: ✔ Converted integers to strings ✔ Used a custom comparator for sorting ✔ Compared (a + b) and (b + a) ✔ Sorted in descending order based on best combination ✔ Handled edge case when all elements are 0 Why this works: By comparing two numbers in different orders, we ensure that the arrangement always produces the maximum possible value when concatenated. 🎯 What I Learned: This problem taught me that sorting can go beyond numbers—custom logic and string manipulation are powerful tools in problem solving. #Java #DSA #LeetCode #Sorting #Comparator #CodingJourney #ProblemSolving #TechSkills 🚀
To view or add a comment, sign in
-
-
🚀 LeetCode Challenge 23/50 💡 Approach: Dynamic Programming + Binary Search This is where it gets serious! We need to pick non-overlapping jobs to maximize profit. Brute force tries all subsets — O(2ⁿ). The winning combo? Sort by end time, then use Binary Search inside DP to find the best previous non-overlapping job in O(log n)! 🔍 Key Insight: → Sort all jobs by their end time → dp[i] = max profit considering first i jobs → For each job: find the latest job that ends ≤ current start (Binary Search!) → Decision: SKIP current job (dp[i-1]) OR TAKE it (dp[lo] + profit) → Take the maximum of both! 📈 Complexity: ❌ Brute Force → O(2ⁿ) Time ❌ DP alone → O(n²) Time ✅ DP + Binary Search → O(n log n) Time, O(n) Space The best solutions often combine two techniques — when DP meets Binary Search, magic happens! 🔮 #LeetCode #DSA #DynamicProgramming #BinarySearch #Java #ADA #PBL2 #LeetCodeChallenge #Day23of50 #CodingJourney #ComputerEngineering #AlgorithmDesign #JobScheduling
To view or add a comment, sign in
-
-
🚀 LeetCode Challenge 30/50 💡 Approach: HashSet (Sequence Start Detection) Sorting would give O(n log n) — but the problem demands O(n)! The trick? Use a HashSet and only start counting from the BEGINNING of each sequence! 🔍 Key Insight: → Add all numbers to a HashSet (O(1) lookup) → For each number, check if (num - 1) exists in set → If NOT → it's the start of a new sequence! → Count upward (num+1, num+2...) while consecutive numbers exist → Update maxLength at each sequence end 📈 Complexity: ❌ Sorting approach → O(n log n) Time ✅ HashSet approach → O(n) Time, O(n) Space Each number is visited at most twice across all sequences! 🎉 Day 30/50 — 60% done and still going strong! The best optimizations come from asking: ‘What information can I precompute?’ A HashSet turned O(n log n) into O(n)! 🔥 #LeetCode #DSA #HashSet #Java #ADA #PBL2 #LeetCodeChallenge #Day30of50 #CodingJourney #ComputerEngineering #AlgorithmDesign #LongestConsecutiveSequence
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟔𝟑 – 𝐃𝐒𝐀 𝐉𝐨𝐮𝐫𝐧𝐞𝐲 | 𝐀𝐫𝐫𝐚𝐲𝐬 🚀 Today’s problem focused on rotating an array to the right by k steps efficiently. 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐒𝐨𝐥𝐯𝐞𝐝 • Rotate Array 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡 – 𝐑𝐞𝐯𝐞𝐫𝐬𝐚𝐥 𝐓𝐞𝐜𝐡𝐧𝐢𝐪𝐮𝐞 • First normalized k using k % n • Reversed the entire array • Reversed the first k elements • Reversed the remaining elements This results in the desired rotation. 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠𝐬 • Reversal technique is a powerful in-place trick • Breaking a problem into steps simplifies logic • Modulo helps handle large values of k • In-place operations reduce space complexity 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲 • Time: O(n) • Space: O(1) 𝐓𝐚𝐤𝐞𝐚𝐰𝐚𝐲 Sometimes the best solution is not shifting elements — but rearranging them smartly. 63 days consistent 🚀 On to Day 64. #DSA #Arrays #TwoPointers #LeetCode #Java #ProblemSolving #DailyCoding #LearningInPublic #SoftwareDeveloper
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