Getting wrong answer in simpler array function of counting number of 0's and 1's

Question: find which number is present with maximum occurrence in array of 0 and 1

c0 is count of 0s and c1 is count of 1s. When c0>c1, your res should be 0 and not 1. And vice versa when c0<c1. I corrected your code. Please check it.