This comment is hidden because it contains spoiler information about the solution
I feel like there must be some way to improve this, that's way more nested loops than there should be
good idea to be more defensive even though positive s is already assumed!
To make it shorter and probably easier to maintain, you could extract returningfrom if-else block, so in condition you only set the value and return it in the very end
Loading collection data...
This comment is hidden because it contains spoiler information about the solution
I feel like there must be some way to improve this, that's way more nested loops than there should be
good idea to be more defensive even though positive s is already assumed!
To make it shorter and probably easier to maintain, you could extract returningfrom if-else block, so in condition you only set the value and return it in the very end