Maximize Weighted Inversion Errors With Wildcards
Asked at Amazon · Coding Questions · Difficulty: Hard · Last asked Apr 16, 2026
You are given a string `s` of `'0'`, `'1'`, and `'!'`. Replace each `'!'` with `'0'` or `'1'`. For the final binary string, let `count10` be the number of index pairs `i < j` with `(s[i], s[j]) = ('1','0')`, and `count01` the number with `('0','1')`. Total errors `= x*count10 + y*count01`. Choose replacements to maximize total errors and return the maximum modulo `1_000_000_007`.
Loading the problem…