
Asked in Paytm
Subsequence Determination Problem
Your task is to verify if the given string STR1
is a subsequence of the string STR2
. A subsequence means characters from STR2
are retained in their original order but some (or none) characters are deleted.
Input:
The first line of input contains an integer ‘T’ denoting the number of test cases. Then for each test case, two separate lines contain: 1. String ‘STR1’ representing the potential subsequence. 2. String ‘STR2’ in which to check for subsequence.
Output:
For each test case, output ‘True’ if ‘STR1’ is a subsequence of ‘STR2’, otherwise ‘False’.
Example:
Input: 3 BAE ABADE ACE ABCDE ADB ABCDE Output: True True False
Explanation:
In the first test case, ‘BAE’ is formed by deleting some characters from ‘ABADE’.
In the second test case, ‘ACE’ is formed from ‘ABCDE’ by removing certain characters without rearranging them.
In the third test case, ‘ADB’ cannot be formed from ‘ABCDE’ due to the order mismatch.
Constraints:
1 <= T <= 50
1 <= N, M <= 10^4
- Where N and M denote the lengths of STR1 and STR2 respectively.
- Strings consist only of English uppercase letters.
- Time limit: 1 second.
Note:
You are not required to print the output explicitly, implementation of the function suffices.

AnswerBot
4mo
Verify if a string is a subsequence of another string by checking if characters are retained in order.
Iterate through both strings simultaneously, checking if characters match in order.
If a character ...read more
Help your peers!
Add answer anonymously...
Top Software Engineer Interview Questions Asked at Paytm
Q. What are the differences between a HashMap and a Hashtable?
Q. How do the web and the internet work?
Q. Given a 2x2 matrix, modify it in such a way that if a cell contains 0, all the e...read more
Interview Questions Asked to Software Engineer at Other Companies
Top Skill-Based Questions for Paytm Software Engineer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

