2380. Time Needed to Rearrange a Binary String You are given a binary string s. In one second, all occurrences of “01” are simultaneously replaced with “10”. This process repeats until no occurrences of “01” exist. Return the number of seconds needed to complete this process. 123456789101112131415161718192021222324class Solution { bool check(string& s) { bool pass = false; for(int i = 0; i < s.length(); i++) { if(pass and s[i] == '1') return true; if(s[i] == '0') pass = true; } return false; }public: int secondsToRemoveOccurrences(string s) { int res = 0, cnt = 0; while(check(s)) { for(int i = 0; i < s.length() - 1; i++) { if(s[i] == '0' and s[i + 1] == '1') { swap(s[i],s[i+1]); i += 1; } } res++; } return res; }};