Cyware interview question

two DSA coding problems with time complexity reasoning