Microsoft software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
Design Rate Limiter Design a rate limiter system that controls the number of requests allowed within a specified time window. The rate limiter is...
Input: StringProblem Statement Design a notification service that supports sending notifications through multiple channels (SMS, Email) and is architected to...
Input: Number(s)Shortest Substring with N Unique Characters *This is a variation of the leetcode problem* Given a string s and an integer n, find the length of...
OA [CodeSignal] Prime Jumps A game is played with the following rules: - A player starts at cell 0 with a score of 0. - There is a row of n cells...
k substitution operations on a number string s. In each operation, choose any digit in s that is...Input: Stringnums. Rearrange nums so that all even numbers appear before all odd numbers. The relative order of even or odd...Input: Arraydef reverse_linked_list(head: Optional[ListNode]) -> Optional[ListNode]:head = [1, 2, 3, 4, 5] [5, 4, 3, 2, 1] head = [1] [1] [0, 5000]. -5000 <= Node.val <= 5000. head. Your task is to reverse the linked list and return the new head node. Ensure that the function can handle edge cases such as an empty list or a single node list.def reverse_linked_list(head: Optional[Node]) -> Optional[Node]: head = 1 -> 2 -> 3 -> None 3 -> 2 -> 1 -> None 1 -> 2 -> 3 to 3 -> 2 -> 1.head = None None None.[0, 5000]. -1000 and 1000. def reverse_linked_list(head: Optional[ListNode]) -> Optional[ListNode]:1 -> 2 -> 3 -> 4 -> 5 -> None5 -> 4 -> 3 -> 2 -> 1 -> None1 -> None1 -> Nonedef reverse_linked_list(head: ListNode) -> ListNode: get(key) and put(key, value). The get method retrieves the value of the key if it exists in the cache. Otherwise, it returns -1. The put method will insert or update the value for a key. If the cache exceeds its capacity, it should invalidate the least recently used item before inserting a new item into the cache.def __init__(self, capacity: int): # Initializes the LRU cache with positive size capacity.def get(self, key: int) -> int: # Returns the value of the key if it exists in the cache, otherwise returns -1.def put(self, key: int, value: int) -> None: # Updates or inserts the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item.cache = LRUCache(2); cache.put(1, 1); cache.put(2, 2); cache.get(1)1 1 was accessed and is now the most recently used.cache.put(3, 3)-1 cache exceeds capacity. 2 is evicted.get(key) and put(key, value). The get method retrieves the value of the key if it exists in the cache, otherwise returns -1. The put method updates or adds the value of the key in the cache. When the cache reaches its capacity, it should invalidate the least recently used entry before inserting a new item. def __init__(self, capacity: int): # initialize LRUCache with positive size capacitydef get(self, key: int) -> int: # return the value of the key, or -1 if the key does not existdef put(self, key: int, value: int) -> None: # update the value of the key or insert the key if it is not already presentlru_cache = LRUCache(2)lru_cache.put(1, 1)lru_cache.put(2, 2)print(lru_cache.get(1)) 1 lru_cache.put(3, 3) 1 <= capacity <= 30000 <= key <= 10^40 <= value <= 10^8s, you need to return the number of palindromic substrings in s. A palindrome is a string that reads the same backward as forward. def count_palindromic_substrings(s: str) -> int:"aaa", Output: 6, Explanation: Substrings are "a", "a", "a", "aa", "aa", "aaa"."abc", Output: 3, Explanation: Substrings are "a", "b", "c".1 <= len(s) <= 1000s consists of lowercase English letters.Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free