ByteDance interview question

TwoSum problem, database questions in mySQL