Hey connections, From one ⭐ to three ⭐ Thrilled to achieve a new milestone on codechef -proof that dedication and continuous learning pay off.
Here are the solution of problems that I solved in today's contest
Problem 1: ANTI ADJACENT SWAPS
Approach:
for n=1 always sorted
for n=2 check array sorted or not
for n=3 two cases for output no
first, if the middle element is smaller than the other two elements, second if the middle element is greater than the other two elements
otherwise the output will be yes
for n>=4 output will be yes.
Problem 2: FREQUAL
Approach: for finding max distinct elements we need to find numbers with minimum factors so we take prime numbers whose factors are two
find n/2 prime numbers then add all n/2
prime numbers twice
if n is odd add one also.
Problem 3: CAESAR CIPHER LITE
Approach: Compare two strings, if characters are not the same, calculate the minimum steps required to change one string into another, Considering the cyclic nature.
Become a pro coder this sumemr. Buy pro at the best price https://www.codechef.com/pro