Problem Statement | |||||||||||||
Given a sequence of bits (0's and 1's), we want to find an arbitrary monotonically increasing curve that best fits the bits. That is, the ith bit is b(i), and we want to find some curve, f, such that for x<y, f(x) <= f(y), and the sum over i of (f(i)-b(i))2 (the squared error) is minimized. Given the sequence of bits as a String[] where you concatenate all the elements together, return the minimum possible squared error. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | Your return must have relative or absolute error less than 1e-9. | ||||||||||||
Constraints | |||||||||||||
- | bits will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of bits will contain between 1 and 50 bits ('0' or '1'), inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|