 # detailed editorial for beginners

#1

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**>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)).

#2

Really helpful for beginners.
Keep up the good work!!

#3

well thanks for explaining it in such a nice way with examples , examples just make it so clear. cannot up vote , wish I could.

#4

well a good initiative to help out beginners.

#5

LITTLE CHEF AND SUMS solution given here is so simple. I solved it the hard way.

#6

#7

Thanks! For the Information.

#8

Can you please provide detailed solution for sereja and commands also .It would be a great help.

#9

see this --> https://www.codechef.com/viewsolution/15219911 it is good solutions of @abx_2109 for sereja and commands.

#10

Minimum good permutation almost ate my mind . Thanks a lot for such easy explanation.

#11

Thanks for the editorial. It was much needed thing I solved the questions in different methods but your approach is also cool.Once again thanks #12

well thanks

#13

thnks mate

#14

haha itw as ezy

#15

yups thanku #16

https://discuss.codechef.com/questions/110979/unofficial-editorial-seaco-and-fill-matrix-briefly

look at this one , and please upvote if it helps.