4 practice questions for Salesforce technical interviews
No verified questions yet for Salesforce.
system designSeniorlogging
[OA] Event Logging System Design — Manage Salesforce's event logging
Salesforce logs various events for user actions. We need to design a system that efficiently stores and retrieves log events based on time stamps and types. The system should support both real-time log retrieval as events occur and historical log query capabilities.Class Definition: class EventLogger: - def log(eventType: str, timestamp: int) -> None: — Records an event with its type and the time it occurred. - def getLogs(eventType: str, startTime: int, endTime: int) -> List[Tuple[str, int]]: — Retrieves events of a specific type that occurred between the given start and end time.Example 1: Input: logger = EventLogger(), logger.log('login', 1), logger.log('logout', 2), logger.getLogs('login', 0, 5) Output: [('login', 1)] Explanation: Returns the log of the 'login' event within the specified time frame.Example 2: Input: logger.log('click', 3), logger.getLogs('click', 1, 4) Output: [('click', 3)] Explanation: Returns the log of the 'click' event within the specified time frame.Constraints: - 1 <= eventType.length <= 100 - 0 <= timestamp <= 10^9
system designSeniorcaching
[OA] LRU Cache — Design a smart caching system for Salesforce's API
Salesforce's API serves numerous requests, making caching an essential feature to enhance performance. Implement an LRU (Least Recently Used) Cache to store API responses. The cache should allow for the following operations: adding a new key-value pair and retrieving a value by key. In case of reaching the cache capacity, the least recently used item should get removed when a new item is added.Class Definition: class LRUCache: - def __init__(self, capacity: int): — Initializes the LRUCache 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 the value of the key if the key exists, otherwise adds the key-value pair to the cache. If the number of keys exceeds the capacity, evict the least recently used key.Example 1: Input: LRUCache(2), cache.put(1, 1), cache.put(2, 2), cache.get(1) Output: 1 (returns the value of key 1)Example 2: Input: cache.put(3, 3) (evicts key 2) then cache.get(2) Output: -1 (key 2 was evicted)Constraints: - 1 <= capacity <= 3000 - 0 <= key <= 10^4 - 0 <= value <= 10^4
codingSeniorgraph
[OA] Graph Traversal — Optimize Salesforce's lead qualification processing
Salesforce processes leads using a network of associated contacts. Implement a method to find the number of unique leads processing through a graph formed by contacts and their relationships. Given a list of contacts represented as pairs of integers where each pair (a, b) indicates a connection between contacts a and b, your task is to find the total number of distinct leads reachable from a given starting contact.Method Signature: def countUniqueLeads(contacts: List[Tuple[int, int]], start: int) -> int:Example 1: Input: contacts = [(1, 2), (2, 3), (3, 4)], start = 1 Output: 4 Explanation: Starting from contact 1, the visible unique contacts are 1, 2, 3, and 4.Example 2: Input: contacts = [(1, 2), (2, 3), (3, 4), (5, 6)], start = 5 Output: 2 Explanation: Starting from contact 5, only contacts 5 and 6 are reachable.Constraints: - 1 <= len(contacts) <= 10^5 - 1 <= contacts[i][0], contacts[i][1] <= 10^6
codingHardsliding window
[OA] Sliding Window — Optimize Salesforce's API request handling
To improve the performance of API requests and reduce response times, Salesforce needs to implement an algorithm to handle bursts of requests within a specific time frame. Given a list of int timestamps representing the arrival times of API requests and an integer windowSize, your task is to determine the maximum number of API requests that can be handled within any windowSize seconds.Method Signature: def maxRequestsWithinWindow(timestamps: List[int], windowSize: int) -> int:Example 1: Input: timestamps = [1, 2, 3, 5, 6] Output: 4 Explanation: The requests at times 1, 2, 3, and 5 can all be handled within a 5-second window (from time 1 to 6).Example 2: Input: timestamps = [1, 3, 6, 8, 10] Output: 3 Explanation: The requests at times 6, 8, and 10 can all be handled within a 5-second window (from time 6 to 11).Constraints: - 1 <= len(timestamps) <= 10^5 - 0 <= windowSize <= 10^6 - 0 <= timestamps[i] <= 10^6
Start practicing Salesforce questions
Sign up for free to access walkthroughs, AI-generated questions, and more.