Java Two Pointer Technique for Subsequence Problem

100 Days of Coding Challenge – Day 18 📌 Problem: Is Subsequence 💻 Language: Java 🧠 Concept Used: Two Pointer Technique 🔍 Platform: LeetCode Today’s challenge was to determine whether a string s is a subsequence of another string t. A subsequence means the characters appear in the same order, but not necessarily consecutively. Approach: ✔ Use two pointers to traverse both strings ✔ If characters match, move both pointers ✔ Otherwise, move the pointer of the second string ✔ If all characters of s are matched, it is a valid subsequence ✔ Time Complexity: O(n) ✔ Space Complexity: O(1) This problem reinforced how powerful the two-pointer technique can be for efficient string traversal. 🔗 Problem Link: https://lnkd.in/g_43jvhm 🔗 Code: https://lnkd.in/gG_7d2BC #100DaysOfCode #Day18 #Java #DSA #LeetCode #TwoPointers #Strings #ProblemSolving #CodingJourney

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories