from collections import Counter def min_s(a: str, s: str) -> str: need = set(a) window = Counter() res = "" c = 0 left = 0 best_len = float('inf') for right, char in enumerate(s): if char in need: window[char] += 1 if window[char] == 1: c += 1 while c == len(need): if right - left + 1 < best_len: res = s[left:right + 1] best_len = right - left + 1 if s[left] in need: window[s[left]] -= 1 if window[s[left]] == 0: c -= 1 left += 1 return res
Python
```python # a = "abc", not-empty, unique (m) # s = "dfaga[bfkac]ebf" => "aceb" (n) O(n) # s = "cfaafb" => "cfaafb" # s = "affb" => "" from collections import Counter def min_s(a: str, s: str) -> str: need = set(a) window = Counter() res = "" c = 0 left = 0 best_len = float('inf') for right, char in enumerate(s): if char in need and \ window[char] += 1 if window[char]: c += 1 ```
""" Given a sequence of integers. Find the minimal possible product of a pair of elements in the sequence (a pair is two elements, not necessarily consecutive). For example, for the sequence 9 4 2 5 3, the answer will be 6. """ def find_min_product(arr: list[int]) -> int: ...
What is the largest amount of data you have had to store in a database?
Have you had experience developing programs with multithreading or asynchrony?
```python from collections import Counter def min_s(a: str, s: str) -> str: need = set(a) window = Counter() res = "" c = 0 left = 0 best_len = float('inf') for right, char in enumerate(s): if char in need and \ window[char] += 1 if window[char]: c += 1 while c == len(need): if right - left + 1< best_len: res = s[left:right + 1] best_len = right - left + 1 if s[left] in need: window[s[left]] -= 1 if window[s[left]] == 0: c -= 1 left += 1 return res ``` The task is to implement a function `min_s(a: str, s: str) -> str` that finds the minimum substring in `s` which contains all characters from string `a`.
from file import ATM, SDK import pytest BILLS = {5000, 1000, 500, 100, 50} @pytest.mark.parametrize( "bills_count_const,expected", [ ({5000: 0, 1000: 0, 500: 0, 100: 0, 50: 0}, False), ({5000: 100, 1000: 100, 500: 100, 100: 100, 50: 100}, True) ] ) def test_false(bills_count_const, expected): atm = ATM(SDK()) atm.bills_count = bills_count_const amount = 1000 res = atm.withdraw(amount) assert res == expected return
What work format do you consider?
How to determine if a specific character (for example, the character A) can be discarded when narrowing the window from the left without losing alphabet coverage?
What data structure can be used to represent a graph in this task?
""" A set of city pairs: - each pair has a direct flight; - the direction of the flight is unknown; - the order of flights is also lost. It is known that all flights belong to one trip. Each subsequent flight starts from the city where the previous one ended. No city was visited twice by the employee. The starting city of the journey is different from the ending city. Output the cities in order of the route. There are two possible answers, any one will do. Examples: ["Moscow", "Belgrade"] -> ["Moscow", "Belgrade"] [("Moscow", "Belgrade"), ("Moscow", "Yerevan")] -> ["Yerevan", "Moscow", "Belgrade"] """ Flight = tuple[str, str] def get_route(flights: list[Flight]) -> list[str]: ..."""
# a = "abc", not-empty, unique # s = "dfagabfkacebf" => "aceb" # s = ""
What is the final complexity of the algorithm after removing the quadratic operation? Is it correct that the size of the alphabet m does not affect the time complexity at all?
What databases or other storage systems do you use in your work?
What is the maximum number of requests per second processed by the highest-load service?
Given a sequence of integers. Find the minimal possible product of a pair of elements in the sequence (a pair is two elements, not necessarily consecutive). For example, for the sequence 9 4 2 5 3, the answer will be 6.
Have you previously considered vacancies at [company], and have you contacted recruiters?