C Pro Assignment 5
C Pro Assignment 5
C Pro Assignment 5
Input format
First line contains N.
2nd line contains the string.
3rd line contains N numbers denoting Ci.
Output format
A single number which is the minimum possible cost
Input1
3
RRR
123
Output1
0
Input2
4
RGBR
1234
Output1
1(change A0 to G ie GGBR)
Constraints
1<=N<=10^6
Ci<=10^3
Input format
First line contains N & M.
2nd line contains N elements, Ai which are the elements of array
Output format
A single number which is the maximum length.
Input1
10 1
1101100111
Output1
5
Explanation
(flip A[2])
Input2
10 2
1101100111
Output2
7
Explanation
(flip A[5],A[6])
Constraints
2 <= N <= 10^6
c) Swapnil Gupta likes to play video games say CSGO and is getting good
at it. He realizes that he needs to spend as much time possible to
become a better player, better than the champion of the batch. He
plans out a schedule in which he knows how much time is available
each day for the next N days in which he can play CSGO. In his model,
time can be negative too. The catch is that his professor should not
know that he plays CSGO, else he will fail him. If he plays CSGO for any
K consecutive days, his professor will catch him. Your task is to find out
the maximum time he can spend playing CSGO in the next N days in
such a way that his professor does not catch him.
Input
First line will have two space separated integers N and K.
Next line will have N space separated integers denoting time on each
day available for the TA to play CSGO.
Output
A single integer denoting the maximum time for which he can play
CSGO in next N days without getting caught by his professor.
Constraints
1 <= N,K <= 1000
-1000 <= Ai <= 1000
Sample Input
53
6 10 8 4 2
Sample Output
22(6+10+4+2)
Input:
String s
k
Output:
Good string s’
Constraints:
1 <= |s| <= 5000
1 <= k <= |s|
Sample Input:
AABBBA
3
Sample Output:
-1
Sample Input:
AAABB
3
Sample Output:
BB
e)
You are given an array of N integers and want to find the Longest increasing
subsequence. Print the indexes of the subsequence you selected. If there are
multiple increasing subsequences with the same length, print the one which
is lexicographically largest(by indexes).
Input:
N
N integers
Output:
L which is the length of LIS
L numbers which are the indexes of lexicographically largest LIS.
Constraints:
N<=5000
Ai<=10^9
Sample Input1:
5
12143
Sample Output1:
3
014
Sample Input1:
7
1231234
Sample Output1:
4
3456
He wants to find the maximum number of letters he can remove in this order
such that it is still possible to get the string p by removing some more
characters (not necessarily in this permutation’s order)(can be 0 more
removals too).
Input:
String S
String P
The permutation A containing |S| integers.
Output:
The maximum no. of characters Anurudh can remove.
Constraints:
|S|<=10^6
Sample Input1:
ababcba
abb
5341762
Sample Output1:
3(string becomes ‘abba’ after 3 removals and ‘bba’ after 4. so he can
remove at most 3 as after 4 removals, ‘abb’ can never be made from
‘bba’)
Sample Input2:
bbbabb
bb
163425
Sample Output2:
4