Jenius Bank Interview Question

Math style leetcode question, leetcode medium / hard