Editorial for Programmers Army Monthly Contest + hiring contest held on CodeChef dated 27th Dec 2020
- It is highly recommended to first just read the explanation of questions that you were not able to solve and then again try to solve that question without going through the solution and after that.
- if you get stuck in coding then you can see solutions to that question.
- If you do not find a solution coded in your preferred language, it is always better to understand core logic and code it out yourself.
- This Contest was purely based on Strings and it’s algorithms.
1. Unique Encryption:
Approach / Explanation: In this problem, you are given a string, and you have to do operations as written step-wise in question ( nothing special here).
Solution coded in C++: https://ideone.com/MbUfaP
2. Remix of Songs:
Approach / Explanation: In this problem, you are given a sentence and you need to find the first word which has a minimum length from the words of the entire sentence, and then you need to print that minimum word to start, end, and between every word of the sentence with whitespaces.
This can be done simply by traversing the given sentence and calculating the length of each word and taking out the word having a minimum length from it.
Solution coded in C++: https://ideone.com/6xZIEg
3. Total Cars :
Approach / Explanation In this problem,
- Create a segment tree with each node consisting of a set which is formed by merging of the sets of its child nodes.
- Each set contains only even numbers.
- For each query, take an empty final set and for every node lying within the given range, push its set values into the final set.
- At the end print the size of this final set.
Solution coded in C++: https://ideone.com/461E9M
4. Smallest String:
Approach / Explanation: In this problem, you are given a string and you need to find the minimized string from the given string which can be any permutation of any length from the given string. also, you can re-arrange the minimized string in any way to form the original string.
Note: There can always, be a solution for any given string. beacause, the original string itself is an integer multiple of itself ( integer value = 1).
You were told to print “-1” if answer doesn’t exist, was just to trick your mind. ( It was intentional ).
Approach : Read code and comments, all things are explained
Solution coded in C++: https://ideone.com/5joyUZ
5. Palindromic Tree:
Approach / Explanation: Basic concept, just go to every node and consider it as the middle of palindrome and also take two adjacent Node and Consider it as a middle of the palindrome.
Solution coded in Python: https://ideone.com/5DG9eX
We hope you enjoyed this contest and learned something new from it, also we hope you will be more excited about such contests in the future also.
Make sure to fill the feedback form, as this is the only way we can work upon our improvements
(if any needed) :
See you at our next Monthly Contest !!