PayPal Interview Question for SDE-3s
- 0of 0 votes
Smallest string- sobby May 03, 2020 in India
You are given the following :
1. Two strings S and T each of Length N
2. K Pairs of integers L(i) and R(i) (0 <= l(i) < R(i) <= N-1)
You can perform any of the following two operations any number of time.
1. You can replace the character of string S at the ith position with the character of string T at the ith position
2. You can select from any provided K pairs and you are allowed to swap characters at position L(i) and R(i) in string T
Now, you are required to perform all the operations optimally so that string S can be lexographically smallest.
All characters of S and T are of lowercase English letters and there are only two ways to perform all the operations either(111...1) then (2222...2) or (2222...2) then (1111.1)
Input Format :
1. First line contains number of test cases:
2. Second line contains the lengths of string and the number of pairs of integers.
3. Next two line contains S and T two strings.
4. The next K lines contains the space separated integers.
Sample Input :
sample output : aaabccaa
| Report Duplicate | Flag | PURGE
PayPal SDE-3 Algorithm
Interview Type: Written Test
Open Chat in New Window