Filter interviews by
Leetcode medium questions, 45 mins
I applied via Job Fair and was interviewed in Nov 2023. There was 1 interview round.
Find k closest points to origin from a set of 2D points.
Calculate distance of each point from origin using distance formula
Sort the points based on distance in ascending order
Return first k points from the sorted list
iOS manual memory management requires developers to manually allocate and deallocate memory for objects.
Developers must manually allocate memory for objects using methods like alloc and init.
Developers must also manually deallocate memory for objects using methods like release.
Failure to properly manage memory can lead to memory leaks and crashes.
ARC (Automatic Reference Counting) was introduced in iOS 5 to automate me...
Program to print powerset of a given set
Create an empty list to store subsets
Loop through all possible binary numbers from 0 to 2^n-1 where n is the length of the set
For each binary number, convert it to binary and use the 1's as indices to select elements from the set
Add the selected elements to the list of subsets
Return the list of subsets
Convert Roman numerals to integer in O(n) time
Create a dictionary to map Roman numerals to integers
Iterate through the string from right to left
If the current numeral is less than the previous, subtract it from the total
Else, add it to the total
Return the total
Given a list of numbers and symbols, provide an expression that evaluates to a target number.
Use recursion to try all possible combinations of numbers and symbols
Check for division by zero and negative numbers
Return False if no expression evaluates to the target number
Solve for x in a given expression with single variable.
Simplify the expression by applying the distributive property and combining like terms.
Isolate the variable term on one side of the equation and the constant terms on the other side.
Solve for x by dividing both sides of the equation by the coefficient of the variable term.
Check the solution by substituting the value of x back into the original equation.
In this case...
Given a hashmap M and an input string S, return an array of all possible mutations of S using M's substitutes.
Iterate through each character in S and get its substitutes from M
Use recursion to generate all possible combinations of substitutes for each character
Time complexity: O(n^m) where n is the average number of substitutes per character and m is the length of S
Space complexity: O(n^m) due to the number of possible...
Facebook implements graph search by indexing user data and using natural language processing.
Facebook indexes user data to create a graph of connections and relationships.
Natural language processing is used to interpret user queries and return relevant results.
Graph search allows users to search for specific information within their network, such as 'friends who like hiking'.
Facebook chat is a real-time messaging service that allows users to communicate with each other through the Facebook website or mobile app.
Facebook chat uses XMPP (Extensible Messaging and Presence Protocol) to enable real-time communication between users.
Messages are sent and received through Facebook's servers, which act as intermediaries between users.
Users can see when their friends are online and available to chat...
Facebook stores likes/dislikes as data points in their database.
Likes and dislikes are stored as separate data points.
Each like/dislike is associated with a unique ID for the post or comment.
The data is stored in Facebook's database and can be accessed through their API.
Likes/dislikes can also be used to personalize a user's newsfeed.
Facebook also uses likes/dislikes to gather data for targeted advertising.
Status updates can be implemented through various methods such as push notifications, real-time updates, and periodic polling.
Use push notifications to instantly update users on important changes.
Implement real-time updates using websockets or server-sent events for a seamless user experience.
Periodically poll the server for updates using AJAX or other similar technologies.
Provide a clear and concise interface for user...
A timeline/newsfeed can be implemented using a combination of algorithms and data structures.
Use a database to store user activity data
Implement an algorithm to sort the data by time
Use pagination to limit the number of items displayed at once
Include options for filtering and searching
Consider using caching to improve performance
Adding someone as a friend allows you to connect with them on the platform and see their updates.
When you add someone as a friend, they receive a notification and can choose to accept or decline your request.
Once they accept your request, you can see their updates and they can see yours.
You can also message each other and tag each other in posts.
Adding someone as a friend does not give them access to your personal info...
Hadoop is a distributed computing framework used for storing and processing large datasets.
Hadoop is based on the MapReduce programming model.
It allows for parallel processing of large datasets across multiple nodes.
Hadoop consists of two main components: HDFS for storage and MapReduce for processing.
It is commonly used for big data analytics, machine learning, and data warehousing.
Examples of companies using Hadoop in
FB messages work by allowing users to send and receive text, images, videos, and other media through the Facebook platform.
Messages can be sent to individuals or groups of people.
Users can also send voice messages and make voice and video calls through the messaging feature.
Messages can be archived or deleted, and users can also choose to ignore or block certain senders.
Facebook uses end-to-end encryption to protect th...
FB Mail is a messaging service that allows Facebook users to send and receive messages from other users.
FB Mail is integrated into the Facebook platform and can be accessed through the Messenger app or website.
Users can send messages to individuals or groups, and can also attach files, photos, and videos.
FB Mail also includes features such as message requests, message filtering, and message archiving.
Messages can be se...
Typing amazon.com in the browser's address bar takes you to Amazon's website.
The browser sends a request to the DNS server to resolve the domain name 'amazon.com' to an IP address.
The browser establishes a TCP connection with the server at the resolved IP address.
The browser sends an HTTP request to the server for the homepage of Amazon's website.
The server responds with the HTML code for the homepage, which the browse
The transaction process involves transferring funds from one account to another. A scheme is designed to ensure secure and accurate transfers.
Verify the availability of sufficient funds in the sender's account
Authenticate the sender's identity and authorization for the transaction
Deduct the transfer amount from the sender's account balance
Initiate a request to transfer the funds to the recipient's account
Validate the r...
When a server receives an HTTP request, it interacts with the operating system, handles threading, thread pooling, synchronization, and hashing.
Upon receiving an HTTP request, the server creates a new thread to handle the request.
The operating system manages the allocation of system resources to the server process.
Thread pooling is used to efficiently manage and reuse threads for handling multiple requests.
Synchronizat...
ACID properties ensure reliability and consistency in database transactions.
ACID stands for Atomicity, Consistency, Isolation, and Durability.
Atomicity ensures that a transaction is treated as a single unit of work, either all or none of its operations are executed.
Consistency ensures that a transaction brings the database from one valid state to another.
Isolation ensures that concurrent transactions do not interfere w...
To find kth-smallest element in BST, perform inorder traversal and return the kth element.
Perform inorder traversal of the BST
Maintain a counter variable to keep track of the number of nodes visited
When the counter reaches k, return the current node's value
If k is greater than the number of nodes in the BST, return null or throw an exception
I applied via LinkedIn and was interviewed in Dec 2022. There were 3 interview rounds.
3 coding questions one on array
Find the second largest element in an array.
Sort the array and return the second last element
Iterate through the array and keep track of the two largest elements
Use a priority queue to find the second largest element
Given a sorted array with repeated elements, find the occurrence of a given element using binary search.
Use binary search to find the first occurrence of the element
Use binary search to find the last occurrence of the element
Calculate the occurrence by subtracting the indices of the last and first occurrences and adding 1
Implement a data structure and algorithm to print all files in a directory, including sub-directories.
Use an n-ary tree or stack to represent the directory structure
Implement a BFS or DFS algorithm to traverse the directory and print files
Handle sub-directories recursively
Consider using a queue or stack to keep track of directories to visit
Print a matrix diagonally.
Start from the top left corner and print the diagonal elements
Move down and right to print the next diagonal
Repeat until all diagonals are printed
DFS is a traversal algorithm used to visit all nodes of a tree or graph. It can be applied to binary as well as n-ary trees.
DFS stands for Depth First Search.
In DFS, we start from the root node and visit its children recursively until we reach a leaf node.
There are two types of DFS: Preorder (root, left, right) and Postorder (left, right, root).
DFS can be implemented using recursion or a stack data structure.
Example: I...
To find the top 10 selling products, sort the products by their sales count in descending order and select the first 10.
Sort the products by their sales count in descending order
Select the first 10 products from the sorted list
Design a valet parking lot with ticket assignment and car retrieval using best fit and nearest distance.
Create a parking lot with designated spots for each size of car
Assign a ticket to the customer upon entry and record the spot number
Retrieve the car by searching for the nearest available spot of the appropriate size
Use best fit algorithm to minimize empty spots
Implement a system for payment upon exit
Trust and Safety Specialist
73
salaries
| ₹5.5 L/yr - ₹9 L/yr |
Software Engineer
63
salaries
| ₹15 L/yr - ₹50 L/yr |
Senior Software Engineer
57
salaries
| ₹24 L/yr - ₹85 L/yr |
Content Reviewer
37
salaries
| ₹3.6 L/yr - ₹9.9 L/yr |
Account Director
31
salaries
| ₹15 L/yr - ₹39 L/yr |
Microsoft Corporation
Amazon