Merge Preferences

How to solve this problem CodeChef: Practical coding for everyone . It would be helpful if somebody provides some insight on solving this one :slight_smile: Thank you in advance :slight_smile: