Https://ide.codingblocks.com/s/121984

only 1 testcase is passing

You need to check your for-loops. The second loop is going only upto the second last element, it is not checking the last element. That is why your test cases are failing. Try to find your mistake and modify the loops so that all elements are checked.