I don't think "IIIII" is a valid input.
However, the expected answer from leetcode is 5.
Many top solutions are simple but don't consider this.
My solution is using a finite state machine.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.