This competitive programming question is bit difficult but I made some test cases that will work for you.
Relevant Skills and Experience
Competitive programmer, check codechef profile wirh name saru_bet and nirmalsarswat400 in hackerrank, nirmal77 on hackerearth
Proposed Milestones
$25 USD - Complete code