FPEvalDataset/LeetCodeProblem
0304
1{2 "id": 3690,3 "name": "smallest_substring_with_identical_characters_i",4 "difficulty": "Hard",5 "link": "https://leetcode.com/problems/smallest-substring-with-identical-characters-i/",6 "date": "2024-12-15 00:00:00",7 "task_description": "You are given a binary string `s` of length `n` and an integer `numOps`. You are allowed to perform the following operation on `s` **at most** `numOps` times: Select any index `i` (where `0 <= i < n`) and **flip** `s[i]`. If `s[i] == '1'`, change `s[i]` to `'0'` and vice versa. You need to **minimize** the length of the **longest** substring of `s` such that all the characters in the substring are **identical**. Return the **minimum** length after the operations. **Example 1:** **Input:** s = \"000001\", numOps = 1 **Output:** 2 **Explanation:** By changing `s[2]` to `'1'`, `s` becomes `\"001001\"`. The longest substrings with identical characters are `s[0..1]` and `s[3..4]`. **Example 2:** **Input:** s = \"0000\", numOps = 2 **Output:** 1 **Explanation:** By changing `s[0]` and `s[2]` to `'1'`, `s` becomes `\"1010\"`. **Example 3:** **Input:** s = \"0101\", numOps = 0 **Output:** 1 **Constraints:** `1 <= n == s.length <= 1000` `s` consists only of `'0'` and `'1'`. `0 <= numOps <= n`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "s = \"000001\", numOps = 1",12 "output": "2 "13 },14 {15 "label": "Example 2",16 "input": "s = \"0000\", numOps = 2",17 "output": "1 "18 },19 {20 "label": "Example 3",21 "input": "s = \"0101\", numOps = 0",22 "output": ""23 }24 ],25 "private_test_cases": [26 {27 "input": [28 "\"111011101011001101110101111010001001010111111001010111011001110100010010101010101000111110010110000010000101010100111111001101100101110010100011111000111001100101001101100101111001011010110000001110111011001010101101110110100000010100001100011110111010011110101001010010010100011011110000101010010010101101000001110110100011111101011101000010001011101110000001110101110111110111011000111001101010110101001111101000111010101001101100010011111011010101011011110001011011000100011111111100100000111110010100010100000101000111100100001010000100011011001011100001100011010111001011010101001001101001111110000001010011100001000000100011011111110001011000101000001011111100111111010011100010111001110010000100100000011111000111000110001001101010001100111100000001010111000110011101010110010010100100000100\"",29 79130 ],31 "output": 132 },33 {34 "input": [35 "\"010001010100011010001010001011011101000001011110000100101001010000100001010111110101011001000100110011111111011101101100101110001111100011110101011011000001101001111110000010001100011110100011011111010101100010000010100000\"",36 16837 ],38 "output": 139 },40 {41 "input": [42 "\"0001001111010111010011001101110100000111011111110001001110111111100110011000110001111000000110100111100110010101000101001001100100001000001100010011001110000010110111001101100101011011100010101110011010100010110010100111111111010001011001101000011000100010110001111100100111011111000000001101101101110000111010000010010011001111101111111011110011010101101101011001100111110111011001000101000101011101000101001001000010110111101011100001100000001110010110000100101010110100110100010011101011111000001001111010110111010101001101110100111110000101000000011111101100000110001010000001100001100110000111000\"",43 25544 ],45 "output": 246 },47 {48 "input": [49 "\"110101001110100001010000010010111100110001011110010111011111111101010010101000010100001000010100100101110100111001010110010000001111011110111101111001110010111111001111100100110110100000101111111001101111110101011000001011110100100010001001010101001000001001001010000001110000010110000000000101111101010011110000011001100011111101000010010011100010100001001001001000010011100010110011100010011101100111100000010110010001111101011011000100111011010000011100000101111100101101100111001111001010101011111010001110000111011101001011010100010000110000011010101010001001110101\"",50 52751 ],52 "output": 153 },54 {55 "input": [56 "\"010000110000101101001100001101010000100000110100000010010111001111001001100010111100001001101111101101101011011110100010110101001111000001111010110100001101111001110100110000010001010101101110001110000101111000111111110001100110011011100001010000010000100010010010110111100100110101111011110011111100100111010010011000000001001110101000100110110110110011011111100111000010010100000010000101001111001111110100101010001111110001001100001010110000111000010000010001110101111010011000111101110001111010011001001100011011110110101100100010010011011110010100100101010010101100001011010001011011001100000011100100010111101101111111000000010110001010001010011011100000101011110000101011001100100001111100010001011010110000000000010110011\"",57 60458 ],59 "output": 160 },61 {62 "input": [63 "\"00101110001110010110011011100000010001001101001001000100111111001010110011000001110000001100011011100111101010110011111001100111110000011101011110010111010101010010001100111101000001001001111010010111001010101110010000010101100100011010000010110100010111111011110110101110110011010011011100001011101000110111100001110111101001111100100011001011000111100001101111110111000001011100010011111010110100010100000100111000100101101100010110100110110100011101010000111100010001010010110110001101010010001111010010101010111000000001111001101\"",64 48765 ],66 "output": 167 },68 {69 "input": [70 "\"1101\"",71 172 ],73 "output": 174 },75 {76 "input": [77 "\"100000011100001001001011010101110000000000011011010001111101110011101000101010010010100111100111001000010101000000010000000011010001011000101101001110101010100101110111100001001011100001010100100000110111100000111000111111010101000111100110111010100110101100110010000100000000111000001011111111111111100111011001001100101010101000100000110101100111110100100101110110000000000011111100010110111011000001001001110011101110011111010100110011000000000111011100010010101100101000010010100101101010100000000001001011001000010010011111110100110110011111101111111001101110110010011011011110001001100000010010010011101100011100100001111010100111001101000001001010100110110010101111111111111100010101000010001000\"",78 1179 ],80 "output": 781 },82 {83 "input": [84 "01101010011001101000011111110101011110000000110101000010011001101000100001111101111111000111101010100000101011110000110100001001111011011111100110010101011010101010110011001000001100110000101000001000010100000100000011011111100100001111001110110100011101100110010111111110011100010100001100100001100010011111001100101100001001101100100100100110010011010101111110101101010011110100110101000",85 29686 ],87 "output": 188 },89 {90 "input": [91 "01010011011001101001010011100100000010011101101011000100000000001011010010100100111110011100011110",92 1493 ],94 "output": 295 }96 ],97 "haskell_template": "minLength :: String -> Int -> Int\nminLength s numOps ",98 "ocaml_template": "let minLength (s: string) (numOps: int) : int = ",99 "scala_template": "def minLength(s: String,numOps: Int): Int = { \n \n}",100 "java_template": "class Solution {\n public int minLength(String s, int numOps) {\n \n }\n}",101 "python_template": "class Solution(object):\n def minLength(self, s, numOps):\n \"\"\"\n :type s: str\n :type numOps: int\n :rtype: int\n \"\"\"\n "102}