[
string
greedy
]
BinarySearch 0385 Rookie Mistake
Problem statement
https://binarysearch.com/problems/Rookie-Mistake/
Solution
Start from ends and move until we blocked.
Complexity
It is O(n)
for time and space.
Code
class Solution:
def solve(self, s):
for x in s:
if x == "B": break
if x == "R": return True
for x in s[::-1]:
if x == "B": break
if x == "R": return True
return False