Day 8/30 – LeetCode #14 (Longest Common Prefix) | Java The challenge here wasn’t complexity, but handling edge cases cleanly. My initial thought was to compare characters column by column, but managing bounds made the logic harder to read. Using the first string as a reference prefix and gradually shrinking it with substring() until it matched all other strings simplified the solution. The startsWith() check kept the code readable while maintaining correctness. This problem reinforced how clarity in string manipulation often matters more than clever logic. #LeetCode #Java #DSA #Strings #ProblemSolving #Consistency #LearningInPublic
LeetCode #14: Longest Common Prefix in Java
More Relevant Posts
-
📝 Day 12/30 – LeetCode #344 (Reverse String) | Java Although reversing a string seems simple, the constraint here is to do it in-place without using extra memory. Using built-in functions would defeat the purpose of the problem. By applying a two-pointer approach, I swapped characters from both ends of the array until they met in the middle. This resulted in a clean O(n) solution with O(1) space. This problem reinforced how even simple tasks can test understanding of constraints and memory efficiency. #LeetCode #Java #DSA #TwoPointers #Strings #Consistency #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Day 66 of #100DaysOfCode | Top K Frequent Elements Solved Top K Frequent Elements using an efficient Bucket Sort–based approach in Java. Approach used: Count the frequency of each element using a HashMap Create a bucket array where the index represents frequency Traverse the buckets from highest to lowest frequency to collect the top k elements Why this approach is efficient: No need to sort the entire array Makes use of the frequency range (1 → n) Works well even for large inputs Time & Space Complexity: Time: O(n) Space: O(n) Key takeaways: Bucket Sort is extremely useful for frequency-based problems Understanding constraints leads to optimal solutions Clean logic beats overcomplicated code Consistency is the real win. On to Day 68 💪 #Day67 #DSA #Java #LeetCode #ProblemSolving #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 2 | Problem 3 of my 15-Day 50+ String DSA Challenge Problem: Swap Two Strings (Without Using a Third Variable) Today I learned how to swap two strings without using an extra variable. Since strings are immutable in Java, the solution uses concatenation and substring logic (with StringBuilder for efficiency). Key learnings: • Strings are immutable, so direct swapping isn’t possible • Concatenation + substring can be used to swap values • Understanding string length and indexing is crucial Building strong fundamentals step by step 💪 #DSA #Java #StringProblems #LearningInPublic #CodingJourney
To view or add a comment, sign in
-
-
Day 68 of #100DaysOfCode 🚀 Today I implemented Pascal’s Triangle using Java. At first glance, it looks like just a pattern problem. But internally, it teaches something powerful — building current state from previous state. 🔹 The first and last elements of every row are always 1 🔹 Every middle element = sum of two elements from the previous row 🔹 This is a classic example of bottom-up thinking Instead of hardcoding values, we dynamically generate each row based on the previous one. This problem strengthened: Nested loop understanding 2D List handling in Java Pattern recognition Thinking in terms of recurrence Small problems. Strong foundations. Consistent progress. On to the next one 💪 #100DaysOfCode #Java #DSA #ProblemSolving #LearningInPublic #dsawithkunal
To view or add a comment, sign in
-
-
Day 23 of #100DaysOfLeetCode 💻✅ Solved #19. Remove Nth Node From End of List on LeetCode using Java. Approach: • Used a dummy node to handle edge cases (like removing the head) • Initialized two pointers: fast and slow • Moved fast pointer n+1 steps ahead to maintain a gap • Traversed both pointers together until fast reached null • Slow pointer stopped just before the node to delete • Updated links to remove the target node in one pass Performance: ✓ Runtime: 0 ms (Beats 100% submissions) ✓ Memory: 43.77 MB Key Learning: ✓ Mastered two-pointer (fast & slow) technique ✓ Understood importance of dummy node for edge cases ✓ Solved the problem in a single traversal (O(n) time, O(1) space) Consistency is building confidence 🚀 #Java #LeetCode #DSA #LinkedList #TwoPointers #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
📝 Day 16/30 – LeetCode #15 (3Sum) | Java This problem extends the two-sum pattern and introduces duplicate handling as the main challenge. A brute-force approach would require checking all triplets, resulting in O(n³) time complexity. By sorting the array and fixing one element, I applied a two-pointer approach on the remaining part of the array. Careful duplicate skipping ensured unique triplets while maintaining efficiency. This optimized the solution to O(n²) time. This problem reinforced how sorting combined with pointer logic can drastically reduce complexity. #LeetCode #Java #DSA #TwoPointers #Arrays #ProblemSolving #Consistency #LearningInPublic
To view or add a comment, sign in
-
-
Day 84/365 ✔️ Solved LeetCode 26 – Remove Duplicates from Sorted Array using Java. A classic two-pointer problem that looks simple but really tests how well you handle in-place updates. Key takeaways from today: • Leveraged the two-pointer technique • Modified the array in-place with O(1) extra space • Preserved the relative order of elements • Reinforced how sorted arrays simplify logic Consistency > intensity. One problem a day, building strong fundamentals. On to the next 🚀 #Day84 #365DaysOfCode #LeetCode #Java #DSA #TwoPointers #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
Solved a few interesting Array problems in Java 1.Minimum Removals to Balance Array Sorted the array first and applied a sliding window / two-pointer approach Goal was to keep elements where max ≤ min × k and remove the rest 2.Shuffle the Array Rearranged elements from the form [x1,x2…xn,y1,y2…yn] → [x1,y1,x2,y2…] Practiced index manipulation and clean iteration logic Good for understanding array positioning problems 3.Transformed Array (Circular Shift Logic) Implemented shifting based on element values (positive → forward, negative → backward) Used modulo arithmetic for circular indexing Helped in index calculations Trying to stay consistent and learn something new regularly 😊 Code is Available on my GitHub https://lnkd.in/guwCQJcw If anyone has suggestions or knows a better approach, please feel free to share 🙌 #DSA #Java #ArrayProblems #ProblemSolving #CodingJourney #Consistency
To view or add a comment, sign in
-
🚀 Day 6 of My 90 Days Java Full Stack Challenge Today, I focused on understanding the theory of String in Java and solved a few basic String problems to build a strong foundation. 📘 What I learned today: What is String in Java Why String is immutable String Constant Pool (SCP) == vs equals() Difference between String, StringBuilder, and StringBuffer How String works internally (memory & performance basics) 🧩 Practice (Basic Level): ✔ Reverse a String ✔ Check Palindrome ✔ Count vowels & consonants ✔ Remove whitespaces 💡 Key takeaway: Before jumping into advanced DSA problems, clarity of concepts matters more than speed. 📅 Plan for tomorrow: 👉 Solve more String DSA problems (intermediate level) and go deeper with hands-on practice. Learning step by step, one day at a time 💪 #Java #StringInJava #90DaysJavaFullStack #DSA #LearningInPublic #Consistency #DeveloperJourney
To view or add a comment, sign in
-
Leetcode Problem | | Check If a String Contains All Binary Codes (1461) 🚀 Problem: Given a binary string s and integer k, check if all possible binary codes of length k exist in the string. Example: s = "00110", k = 2 Expected Output = true In substring and sliding window problems, boundary conditions matter more than logic sometimes. Consistent debugging > frustration. #DSA #Java #LeetCode #ProblemSolving #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