Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions String/2124. Check if All A's Appears Before All B's.py

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Tags: String
class Solution:
def check_string(self, s: str) -> bool:
"""
Time Complexity: O(n) where n is the length of string s
- We iterate through the string exactly once
Space Complexity: O(1)
- Only a single boolean variable is used
"""
is_b_appear = False
for c in s:
if c == 'b':
is_b_appear = True
else:
if is_b_appear:
return False
return True
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pytest
from tests.base_test import BaseTestSolution
from .solution import Solution


class TestSolution(BaseTestSolution):
solution = Solution()

@pytest.mark.parametrize("method_name, s, expected, timeout", [
('check_string', "aaabbb", True, None),
('check_string', "abab", False, None),
('check_string', "bbb", True, None),
])
def test_check_string(self, method_name, s, expected, timeout):
self._run_test(self.solution, method_name, (s,), expected, timeout)
Loading