FPEvalDataset/LeetCodeProblem
0304
1{2 "id": 2464,3 "name": "time_needed_to_rearrange_a_binary_string",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/time-needed-to-rearrange-a-binary-string/",6 "date": "1659744000000",7 "task_description": "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._ **Example 1:** ``` **Input:** s = \"0110101\" **Output:** 4 **Explanation:** After one second, s becomes \"1011010\". After another second, s becomes \"1101100\". After the third second, s becomes \"1110100\". After the fourth second, s becomes \"1111000\". No occurrence of \"01\" exists any longer, and the process needed 4 seconds to complete, so we return 4. ``` **Example 2:** ``` **Input:** s = \"11100\" **Output:** 0 **Explanation:** No occurrence of \"01\" exists in s, and the processes needed 0 seconds to complete, so we return 0. ``` **Constraints:** `1 <= s.length <= 1000` `s[i]` is either `'0'` or `'1'`. **Follow up:** Can you solve this problem in O(n) time complexity?",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "s = \"0110101\"",12 "output": "4 "13 },14 {15 "label": "Example 2",16 "input": "s = \"11100\"",17 "output": "0 "18 }19 ],20 "private_test_cases": [21 {22 "input": "00000000001100100110010110001010010100011101110100111010111100000011000111111101011100000011110101001001001111001011001110001010001010000010110110111011010111001111111011100000010111110010100111110001110100010101010101001100010011100101000011111011011001001111001000100100100000111111000100001101000111010100101111010011111101001100111110111101000110100111011000101001010011100",23 "output": 20424 },25 {26 "input": "101101110011100110111111000000111100111110000011111100100011110110111110000000100011000101001000000101101100001010001011011011100110010100110101111101001000100101010011110100100000111101000100111000000111100011010000100011000001011011011100001000011110100000011000010111100110001111101001101000011101110101010110010011001011111001001010111110101011101111010101111010101111000000011010011110100110110110010001011010010100110110000001110101111011000010001001000101010100010011000100001111000001011110100001111111101111011000111100100000100010110001101101000010110011111110110101101110111100010011110101111101011001110101000111011111110001001100110001110011001011001000011100001111000001000110110011010011111011100000110001101100010010100011001011001100011010010001010100001111000001110110011110001100101100010000101110111111011010010111001010000010111101010111111100101011100001110001010110000101110100010010111001001101110101111101001111001101010011101100101000110011100100001000000010000",27 "output": 51028 },29 {30 "input": "10010011111101010110111111001111011110101100100100100011101011001011001001110001101111100",31 "output": 5332 },33 {34 "input": "1100101110101001010101010001101100001000011001000101011111000100111010101101011001001110011011010100101111101001011011010010101001110111011001111101001010110010010001001110101110111010110111101101010010100001111011101001110000110111110110110110110101010100001111011100101111110001100011111101100001100110",35 "output": 17336 },37 {38 "input": "10100000000110111000001000100100011011000011101100001100111010011001010110110011110010001110100010000110111011101100101101001011001010010101100011011101000000011101011101111010111111101010111111010011000000100011011011100111000",39 "output": 12740 },41 {42 "input": "101011101110001001010100100100010101011010101001100101011000100101110000110000010101001001001010111011100101110101000000000001000011011110111110100001110000010001101111110110111000001011111011100010010110010100111110111000001101100110010101000000100100111000100010111111001110111000101110110100111001010100010001000000100010101001001000000110010111110011000011111001101110110100110100010111000000000001111111010011010111111001011011100",43 "output": 23744 },45 {46 "input": "01011110000110010110000001100100010011100100010001111000010110010101101100101100101010010110000010100111100100100001011101110111101101010000100010110111000100010001011010000010110001000011001011100000000010011001001110100100110010110111001110001101111100010010110010100000100011101010100111011001110001111101111111110001010100011000010101010001011100001100000101100101111010000011000001100110001010110110101100001001011110101010111010011011000000001011010000001011101111001011001111001101011101011100100111111000000111010101000111110000111011000001010001100011",47 "output": 30448 },49 {50 "input": "010001001001011111000101110010001010000101000110100001110010000110010101000010001010001111011001011101010100001010110001101001001111010000001110001010000101011010011110110011001001001000011101110011101100001110010001111000011100100111100101001010111100011100110011100111110000111110110100000111111001110010100000001001101110101010101100001001100100000101101100111011010111100111100101100011000110110100010100001001010000010100111011110111001101110111101001110000010011000110110011010001111100101101011100100001011000111001100010101011110101101110100010011100011010101011100110100010110100010011001110111011000011011111001011001000001100001010011000000000100010000101001100010110010100100001000100000100100001000011010100100000111010110110101101001001101111100000100001111100010110010010111000000010001101011100100000110001101111111000000111011001001101001001001000101100101001101000011100100111111011000010010111100111100011100100011010101100001011101000000001000101110010101",51 "output": 52252 },53 {54 "input": "0100100001111010100100001011100001110110010101010100110001011110011000010000110111001000110000000010111001011111101111111000111100101101101",55 "output": 8456 },57 {58 "input": "0101011000011000100111101011110100000101000000111100100111001010011001011010100100001100010101100011101001101100001001101101000110011000100111110010101101110001001100010000110000010001110010111101100001001011010110011100111111101001100001101101111111010000011001000001011111110101111110111100101111111000101100101100101001010001111001010001111000000110010100110010100011110111011100100001111011010010101000011101111110100101110001111100111110001",59 "output": 24760 }61 ],62 "haskell_template": "secondsToRemoveOccurrences :: String -> Int\nsecondsToRemoveOccurrences s ",63 "ocaml_template": "let secondsToRemoveOccurrences (s: string) : int = ",64 "scala_template": "def secondsToRemoveOccurrences(s: String): Int = { \n \n}",65 "java_template": "public static int secondsToRemoveOccurrences(String s) {\n\n}",66 "python_template": "class Solution(object):\n def secondsToRemoveOccurrences(self, s):\n \"\"\"\n :type s: str\n :rtype: int\n \"\"\"\n "67}