Zco 2018 questions:
1) You have C cakes and N children and k. Each child has a range between Si and Ei inclusive. A child will eat all the cakes lying between the range.
If k = 0, you have answer if any of the students' ranges clash or not.
If k = 1, then, you are allowed to move at max 1 child from his place. Let's say you have 5 cakes, and the range of 2 kids are [2,2] and [2,5], then the kids will fight over the second cake. To avoid this you are allowed to move at max one child from its place and allot him another range. If you can remove all the clashes by shifting 1 child then print Good, otherwise print Bad.
5(N) 2(C) 0(K)
5 2 1
5 2 1
In test case 2, the child with range [2,2] can be moved from his place to [1,1]
2) You have string of length N consisting of X, Y and Z. A string is good if it starts with X, ends with Z and has a length divisible by 3.
The importance of a string is the number of good string it intersects with.
Given the string and a length k, find a string of length exactly K and minimize it's importance. You have to print its importance.
X Y Z Z Y X X Y Z
Y X Y Z
In test cases 1, the good strings are from [0,2], [0,8], [6,8]. The string of minimum importance of length 3 is present at [3,5].
In test case 2, the only good string is from [1,3]. Any string of length 2 will at least have an importance of 1. So the answer is 1.