Amazon's database doesn’t support very large numbers, so numbers are stored as a string of binary characters, '0' and '1'. Accidentally, a '!' was entered at some positions and it is unknown whether they should be '0' or '1'.
The string of incorrect data is made up of the characters '0', '1', and '!' where '!' is the character that got entered incorrectly. '!' can be replaced with either '0' or '1'. Due to some internal faults, some errors are generated every time '0' and '1' occur together as '01' or '10' in any subsequence of the string. It is observed that the number of errors a subsequence '01' generates is xxx, while a subsequence '10' generates yyy errors.
Determine the minimum total errors generated. Since the answer can be very large, return it modulo 109+710^9 + 7109+7.
For example, given string errorString = "101!1"
, x=2x = 2x=2, y=3y = 3y=3:
Function Description
Complete the function getMinErrors
in the editor below.
getMinErrors
has the following parameter(s):
string errorString
: a string of characters '0', '1', and '!'int x
: the number of errors generated for every occurrence of subsequence 01int y
: the number of errors generated for every occurrence of subsequence 10
Returns
int
: the minimum number of errors possible, modulo 109+710^9 + 7109+7
Constraints
经过我们的强力面试辅助,OA代写,候选人通过这些面试题的解析和沟通,面试官不仅了解了候选人的编程能力,也看到了我在解决问题过程中清晰的思路和有效的沟通技巧。这些不仅有助于应对 Meta 的面试,同时也能提升我们解决实际编程问题的能力。祝大家面试顺利!
如果你也需要我们的面试辅助服务,请立即联系我们。