This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
kse-02/instrumented/longest_substring.py

18 lines
506 B
Python
Raw Normal View History

2023-11-13 15:33:20 +00:00
def longest_sorted_substr_instrumented(s: str) -> str:
2023-11-13 15:33:20 +00:00
count = 0
max_count = 0
end_position = 0
for char in range((len(s) - 1)):
if evaluate_condition(1, 'LtE', s[char], s[(char + 1)]):
count += 1
if evaluate_condition(2, 'Gt', count, max_count):
max_count = count
end_position = (char + 1)
else:
count = 0
start_position = (end_position - max_count)
return s[start_position:(end_position + 1)]