No one has replied
@simonwoo Thanks for letting me know.
I think what is wrong is the testcase, not my solution, which I have pointed out. so please check my new post:
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.