Why is my DSU approach not working?

My code is only passing 1 test case.