Flip Time : Space : 12345678910111213141516171819vector<int> Solution::flip(string A) { if(count(begin(A), end(A), '1') == A.size()) return {}; int now = 0, ma = 0, map = 0, pick = 0, n = A.size(); vector<int> res; for(int i = 0; i < n; i++) { if(A[i] == '1') now += 1; else now -= 1; if(now > ma) { ma = now; map = i + 1; } if(ma - now > pick) { pick = ma - now; res = {map + 1, i + 1}; } } return res;}