I\'ve tried to do this exercise myself but I couldn\'t make it work properly for negative intervals.
Then I implemented the version from geeksforgeeks and I get the s