String Manipulation

Posted: 4 Jul, 2016
Difficulty: Moderate

PROBLEM STATEMENT

Try Problem

You are given a string S consisting of only lowercase alphabets of length at most 100 . A string T is created by concatenation of k copies of string S. Some changes are done to do in string T, such as -

You can pick a number p and character c and delete the p-th occurrence of character c from the string T

It is guaranteed that the letter to be deleted always exists, and after all operations not all letters are deleted from the string T. The letters' occurrences are numbered starting from 1.

Given string S, integer k and all the operations performed, you need to figure out the final string generated. N is the total number of operations performed. For every operation, p and c is given.

Input Format :
Line 1 : Integer k 
Line 2 : A non-empty string S
Line 3 : Integer n
Next n lines : pi and ci, separated by space
Output Format :
Print a single string — final string after all changes are applied to it
Constraints :

1 ≤ k ≤ 2000

1 ≤ pi ≤ 200000

Working on approaches!
Meanwhile, please head to Code Editor and try the problem there.