I am trying to solve a problem from Leetcode and could not figure out how to solve it. I looked up the solution but I cannot understand how switching the element can change