Submitted by: Mohammad Sajid Anwar
You are given a string.
Write a script to return the power of the given string.
The power of the string is the maximum length of a non-empty substring that contains only one unique character.
Input: $str = "textbook"
Output: 2
Breakdown: "t", "e", "x", "b", "oo", "k"
The longest substring with one unique character is "oo".
Input: $str = "aaaaa"
Output: 5
Input: $str = "hoorayyy"
Output: 3
Breakdown: "h", "oo", "r", "a", "yyy"
The longest substring with one unique character is "yyy".
Input: $str = "x"
Output: 1
Input: $str = "aabcccddeeffffghijjk"
Output: 4
Breakdown: "aa", "b", "ccc", "dd", "ee", "ffff", "g", "h", "i", "jj", "k"
The longest substring with one unique character is "ffff".
Submitted by: Mohammad Sajid Anwar
You are given instruction string made up of U (up), D (down), L (left) and R (right).
Write a script to return true if following the instruction, you meet the starting point (0,0).
Input: $path = "ULD"
Output: false
(-1,1) <- (0,1)
| ^
v |
(-1,0) (0,0)
Input: $path = "ULDR"
Output: true
(-1,1) <- (0,1)
| ^
v |
(-1,0) -> (0,0)
Input: $path = "UUURRRDDD"
Output: false
(0,3) -> (1,3) -> (2,3) -> (3,3)
^ |
| v
(0,2) (3,2)
^ |
| v
(0,1) (3,1)
^ |
| v
(0,0) (3,0)
Input: $path = "UURRRDDLLL"
Output: true
(0,2) -> (1,2) -> (2,2) -> (3,2)
^ |
| v
(0,1) (3,1)
^ |
| v
(0,0) <- (1,0) <- (1,1) <- (3,0)
Input: $path = "RRUULLDDRRUU"
Output: true
(0,2) <- (1,2) <- (2,2)
| ^
v |
(0,1) (2,1)
| ^
v |
(0,0) -> (1,0) -> (2,1)
Last date to submit the solution 23:59 (UK Time) Sunday 30th November 2025.