Комментарии 2
The first algorithm seems to be wrong.
Assume A = [0, 100], B = [2, 1], x = 10.
Then the correct answer is 1 (just nullify the second component).
While your algorithm will return -1
Зарегистрируйтесь на Хабре, чтобы оставить комментарий
LeetCode, Hard, last two problems: 2809. Min Time to Make Array Sum At Most x & 2813. Max Elegance of a K-Length Subseq