I have seen everyone posting solutions to the tough questions , but considering newbies the initial questions also need proper explanations so that they can proceed further.

LITTLE CHEF AND SUMS:-

The question says u need to find the least(prefix sum+suffix sum) for n elements. So the common observation is if you do prefix+suffix , that will always remain equal to the total sum +the element at which you are doing that , so in order to find the least pre+suff , you can only find the minimum element in the array and display index+1.(there are many other waist do it.)

There is the solution link below.

```
https://www.codechef.com/viewsolution/15373052
```

MINIMUM GOOD PERMUTATION:-

The question is bit confusing to start of , but if you have a look at the input and output section you will easily find the solution.

For e.g.- if you have. n=6 then then answer is 2 1 4 3 6 5 (the common observation is 1 2 3 4 5 6 gets swapped and we reach there.) but if you take n=7 then 2 1 4 3 6 7 5 (the normal would have been 1 2 3 4 5 6 7, so for this just swap till n-1 and at the end again swap the last two elements.)

```
The solution is https://www.codechef.com/viewsolution/15183357
```

CHEF AND PICK DIGIT:-

The questions seems easy enough though, but when you look at the constraint , you need to take the input as string , one more thing is there you need to print the characters alphabetically. So why not read the question from back , for instance if A can be made from the numbers then print A , if B can be made then print B , and so on till Z .

Take an example of 778654891, then just make frequency array of 10 numbers initialized to 0 everywhere.

So your freq array,looks something like this

0 1 0 0 1 1 1 2 2 1 so based on 0-based indexing you can simply store the frequency of each digits and refer to it by O(1).

Now you need to check from A-Z whether its there or not so , just run a loop from 65-90. so for(65,90) and i=65 at first instance so a=I%10 and b=I/10 will give u a=5 and b=6 so you just need to check if its there or not freq[a]>0 and freq[b]>0 , if then print char(i) in c++ will print the character with ASCII value i. When you come down 66 , so 6 has to be present more then once so freq[a]>1 since you can use the same positions 6 twice as mentioned in the question, and you are done .

```
The solution is https://www.codechef.com/viewsolution/15183326.
```

The complexity is O(len(s)).