10+ Interview Questions and Answers
Q1. Given a hashmap M which is a mapping of characters to arrays of substitute characters, and an input string S, return an array of all possible mutations of S (where any character in S can be substituted with one...
read moreGiven 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 combinations
Optimization: Use memoization to store previo...read more
Q2. Given a list of integer numbers, a list of symbols [+,-,*,/] and a target number N, provide an expression which evaluates to N or return False if that is not possible. e.g. let the list of numbers be [1,5,5] an...
read moreGiven 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
Q3. How will you describe iOS manual memory management for a new developer in few words?
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 memory management.
However, manual memory management is still...read more
Q4. Write a program to print the powerset. E.g. given this set {1,2,3}, it will print {},{1},{2},{3},{1,2},{1,3}, {2,3}, {1,2,3}
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
Q5. Given an expression (in single variable) like 4x+13(x-(4x+x/3)) = 9, evaluate x The expression is a string and the variable is always x
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, simplify the expression to -5x/3 = -4 and solve for x to...read more
Q6. Brain storming:How does facebook implement graph search
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'.
Q7. Given a set of 2D points, some integer k, find the k points closest to the origin, (0,0)
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
Q8. Explain more about hadoop and how it is used ?
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 include Facebook, Yahoo, and eBay.
Q9. Convert a string of Roman numerals to an integer in O(n) time
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
Q10. How do u implement status updates ?
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 users to view and interact with status updates.
Consider implem...read more
Q11. How does fb store likes/dislikes ?
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.
Q12. How do fb messages work ?
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 the privacy and security of messages.
Messages can be accesse...read more
Q13. How does fb mail work ?
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 sent and received in real-time, and users can also receive n...read more
Q14. How does facebook chat work
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, and can also send messages to offline friends that will ...read more
Top SDE Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month