Skip to main content

Command Palette

Search for a command to run...

Is Subsequence

Published
1 min read
Is Subsequence
G

As a Systems Engineer at Tata Consultancy Services, I deliver exceptional software products for mobile and web platforms, using agile methodologies and robust quality maintenance. I am experienced in performance testing, automation testing, API testing, and manual testing, with various tools and technologies such as Jmeter, Azure LoadTest, Selenium, Java, OOPS, Maven, TestNG, and Postman.

I have successfully developed and executed detailed test plans, test cases, and scripts for Android and web applications, ensuring high-quality standards and user satisfaction. I have also demonstrated my proficiency in manual REST API testing with Postman, as well as in end-to-end performance and automation testing using Jmeter and selenium with Java, TestNG and Maven. Additionally, I have utilized Azure DevOps for bug tracking and issue management.

Given two strings s and t, return true if s is a subsequence of t, or false otherwise.

A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not)

LeetCode Problem - 392

class Solution {
    // Method to check if s is a subsequence of t
    public boolean isSubsequence(String s, String t) {
        // If s is longer than t, s cannot be a subsequence of t
        if(s.length() > t.length()) return false;

        // Initializing pointers for s and t
        int i = 0, j = 0;

        // Iterating through both strings
        while (i < s.length() && j < t.length()){
            // If characters at current positions match, move to next character in s
            if (s.charAt(i) == t.charAt(j)){
                i++;
            }
            // Move to next character in t
            j++;
        }

        // If all characters in s are found in t in the same order, return true
        return i == s.length();
    }
}

More from this blog

S

Software and Performance Testing Insights

462 posts

Results-Driven Agile QA Specialist | Expert in Mobile & Web Testing | Proficient in Test Planning, Execution, and Root Cause Analysis.