Download 125/solution/_reference.py from PRHW/loom-benchmark-mbpp: direct link, hf CLI and curl.
- Browser
- Download file 259 Bytes
-
https://huggingface.co/datasets/PRHW/loom-benchmark-mbpp/resolve/main/125/solution/_reference.py
- Command line
-
hf download hf://datasets/PRHW/loom-benchmark-mbpp/125/solution/_reference.py
-
curl -L -o _reference.py https://huggingface.co/datasets/PRHW/loom-benchmark-mbpp/resolve/main/125/solution/_reference.py
259 Bytes
| def find_length(string): | |
| n = len(string) | |
| current_sum = 0 | |
| max_sum = 0 | |
| for i in range(n): | |
| current_sum += (1 if string[i] == '0' else -1) | |
| if current_sum < 0: | |
| current_sum = 0 | |
| max_sum = max(current_sum, max_sum) | |
| return max_sum if max_sum else 0 |