Microsoft OA question 2023 | Intern
Anonymous User
250

Given a string and an array C. C contains the index where we insert character '' between two adjacent same characters.
Note : C follows 1 based indexing.
For Eg: string s: "aaa" , C=[2,3]
After operation C[0]=1, we get s="aa$a"
Thus answer is 2.

Note C may or may not be sorted.

Constrainsts
string size <= 5*10^4
Size of C < (string size)

I solved it using binary search.

Comments (2)