Compare Strings
Practice
3.8 (38 votes)
Algorithms
Basic programming
Binary search
Easy
Searching
String manipulation
Problem
85% Success 19093 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
You have been given two strings, A and B (of length N each) and Q queries.
The strings contain only 0s and/or 1s.
For every query, you are given an index i. You have to update the value at index i to 1 in string B and check if B is lexicographically equal to or larger than A or not.
If yes, then print "\(YES\)" and if not, print "\(NO\)" (without quotes).
Input format
- First line contains two space-separated integers N and Q.
- Next line contains the string A.
- Next line contains the string B.
- Next Q lines contains an integer i (1 - based indexing)
Output Format
For each query, print the desired output in a new line.
Input Constraints
\(1 \le N\) , \(Q \le 10^6\)
\(1 \le i \le N\)
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
1.Coins
Points:20
15 votes
Tags:
AlgorithmsBinary SearchEasySearchingTwo pointer
Points:20
39 votes
Tags:
AlgorithmsApprovedBinary SearchEasyGrammar-VerifiedRecruitSearching
Points:20
25 votes
Tags:
AlgorithmsBinary SearchEasySearching
Editorial
Login to unlock the editorial