LeetCode-Solution My Own Solution With CPP/JAVA The Time Complexity and Space Complexity should be optimal