Any tips on how to write elegant code?

For a majority of the problems that I solve on Leetcode, my solution is filled with if-else and complex conditionals. Although it gets accepted, when I turn to check the solution, I find the solution there is much more concise and elegant with only the necessary if-else conditions.
How do I practice writing concise code? Any tips would be greatly appreciated.

Comments (1)