xAI software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
No verified questions yet for xAI.
UserSessionManager class is critical for xAI to handle user sessions securely and efficiently. It requires proper management of user logins, session timeouts, and session validation to ensure a consistent user experience across devices.login(user_id: str) -> str: Logs in a user and returns the session ID.logout(session_id: str) -> None: Logs out a user by invalidating their session ID.is_valid_session(session_id: str) -> bool: Checks if the session ID is valid.get_session_data(session_id: str) -> dict: Retrieves the session data associated with a session ID.4. Example 1:login('user123') → Output: session_id_abcuser123 successfully logs in and receives a session ID.5. Constraints:POST /train, GET /predict, and GET /status. Ensure to consider versioning and error handling in your design.1000 concurrent requests with low latency.put(key: int, value: int): void and get(key: int): int. When the cache reaches its capacity, it should invalidate the least recently used (LRU) item. class LRUCache:def __init__(self, capacity: int): Initializes the cache with a positive size capacity.def get(self, key: int) -> int: Returns the value of the key if the key exists, otherwise returns -1.def put(self, key: int, value: int) -> None: Updates or adds the value if the key is not present. When the cache reaches its capacity, it should invalidate the least recently used item before adding the new item.1 <= capacity <= 30000 <= key <= 100000 <= value <= 10^9.get(key: int) -> int: Retrieve the value of the key if the key exists in the cache, otherwise return -1.put(key: int, value: int) -> None: Update the value of the key if the key exists. If the key does not exist, add the key-value pair to the cache. If the cache reaches its capacity, it should invalidate the least recently used item before inserting a new item.def get(self, key: int) -> intdef put(self, key: int, value: int) -> Nonecache = LRUCache(2), cache.put(1, 1), cache.put(2, 2), cache.get(1) 1 Example 2: cache.put(3, 3), cache.get(2) -1 capacity is at most 3000.Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free