Thinking process, prefix sums
The idea is that a \'0\' at index \'i\' is reachable only if there exists a reachable \'0\' in the range [i - maxJump, i - minJump]. \nSo we need to somehow cou
The idea is that a \'0\' at index \'i\' is reachable only if there exists a reachable \'0\' in the range [i - maxJump, i - minJump]. \nSo we need to somehow count the number of reachable zeros between any range [i, j]. In order to do this we can use prefix sums. \nIf a \'0\' is reachable, then we add 1 to the current prefix sum, else we just keep the current one.\n```\nclass Solution {\npublic:\n    bool canReach(string s, int minJump, int maxJump) {\n        vector<int> prefixSums(s.size());\n        prefixSums[0] = 1;\n        \n        for (int i = 1; i < s.size(); i++) {\n            if (s[i] == \'1\') {\n                prefixSums[i] = prefixSums[i - 1];\n            }\n            else {\n                int lowerBoundIndex = max(i - maxJump, 0);\n                int upperBoundIndex = i - minJump;\n                \n                if (upperBoundIndex < 0) {\n                    prefixSums[i] = prefixSums[i - 1];\n                    continue;\n                }\n                \n                int lowerSum = lowerBoundIndex - 1 < 0 ? 0 : prefixSums[lowerBoundIndex - 1];\n                int upperSum = prefixSums[upperBoundIndex];\n                \n                if (upperSum - lowerSum > 0) {\n                    if (i == s.size() - 1) {\n                        return true;\n                    }\n                    prefixSums[i] = prefixSums[i - 1] + 1;\n                }\n                else prefixSums[i] = prefixSums[i - 1];\n            }\n        }\n        \n        return false;\n    }\n};\n```
[]