We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
From start, bring each odd to its right side odd neighbors to eliminate.
deffairRations(B):# 1 is odd, 0 is evenb=[n%2forninB]ifsum(b)%2:return'NO'# bring each pair of odds together to eliminateodds=[ifori,_inenumerate(b)if_]res=0i=0whilei<len(odds):res+=(odds[i+1]-odds[i])*2i+=2returnstr(res)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Fair Rations
You are viewing a single comment's thread. Return to all comments →
Python
From start, bring each odd to its right side odd neighbors to eliminate.