Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Facebook interview experience Real time questions & tips from candidates to crack your interview
SDE - 1
Facebook
upvote
share-icon
4 rounds | 10 Coding problems
Interview preparation journey
expand-icon
Preparation
Duration: 4 Months
Topics: Data Structures, Algorithms, System Design, Aptitude, OOPS
Tip
Tip

Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.

Application process
Where: Campus
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.

Interview rounds
01
Round
Hard
Online Coding Test
Duration90 minutes
Interview date10 Jul 2021
Coding problem2

This was an online coding round where we had 2 questions to solve under 90 minutes . Both the questions were preety hard according to me . One has to have a fair share of knowledge in Data Structures and Algorithms to pass this round .

1. Longest Increasing Path In A 2D Matrix
Hard
10m average time
90% success
0/120
Asked in companies
IBMGooglePhone Pe

You have been given a MATRIX of non-negative integers of size N x M where 'N' and 'M' denote the number of rows and columns, respectively.

View more
Problem approach

This was one of the most interesting questions I faced in all my campus interviews . I was initially thinking of using recursion and then optimising it through memoisation but there was a risk of getting TLE . I then observed that this question can be transformed into a Topological Sort+DP question where I was required to find the length of the longest chain ending at a particular index . ...

View more
Try solving now
2. Saving Money
Moderate
20m average time
80% success
0/80
Asked in companies
FacebookShareChatAccenture

Ninja likes to travel a lot, but at the same time, he wants to save as much money as possible.


There are ‘N’

View more
Problem approach

It seems that Facebook loves Graph questions . This was also a Graph question particularly related to Bellman Ford Algorithm .

Steps :
1) Initiliase a DP array with all INT_MAX , where dp[i][j] stores the min distance to reach j from source using atmost i edges.
2) For all i from 0 to k+1 , dp[i][src]=0 as min distance to reach source (src) using any no. of edges is always 0 .
3...

View more
Try solving now
02
Round
Medium
Video Call
Duration60 Minutes
Interview date12 Jul 2021
Coding problem2

This Round was DS and Algo round and it started with formal introduction, followed by 2 problems. We first dicussed the
approach the time complexity and proper code covering all cases.

1. K - Sum Path In A Binary Tree
Moderate
35m average time
65% success
0/80
Asked in companies
AdobeJP MorganWalmart

You are given a binary tree in which each node contains an integer value and a number ‘K’. Your task is to print every path of the binary tree with the sum of nodes in the path as ‘K’.

Note:

View more
Problem approach

The idea is simple: along the path, record all prefix sums in a hash table. For current prefix sum x, check if (x - target)
appears in the hash table.
Steps :
1) We will be using a unordered map which will be filled with various path sum.
2) For every node we will check if current sum and root’s value equal to k or not. If the sum equals to k then
increment the required answer by...

View more
Try solving now
2. Combination Sum
Easy
15m average time
85% success
0/40
Asked in companies
LinkedInSalesforceMakeMyTrip

You are given an array 'ARR' of 'N' distinct positive integers. You are also given a non-negative integer 'B'.


View more
Problem approach

Since the constraints were small , I followed a recursive+backtracking approach for this problem

Approach :
1) Create a recursive function called recur (void recur(vector&arr , vectortmp , int target,int idx) ) which would eventually fill my answer vector with all the possible combination sums for the given target.

2) For every element , I have 2 choices -
2.1) To take t...

View more
Try solving now
03
Round
Medium
Video Call
Duration50 Minutes
Interview date12 Jul 2021
Coding problem3

This Round was DS/Algo + Core round and it started with formal introduction, followed by 3 problems. We first dicussed
the approach the time complexity and proper code covering all cases for the 2 coding problems . The last question was
related to OS and was a bit theoretical .

1. Accounts Merge
Hard
15m average time
85% success
0/120
Asked in companies
AmazonFacebookPhone Pe

You have been given an array/list 'accounts' where each element, i.e. 'accounts'[i] contains a list of strings.


View more
Problem approach

My Interviewer took some time in explaining this problem to me as the problem statement of this question was quite long and complicated . After thoroughly understanding the question , my first observation was to apply DFS and solve this problem but some time later the thought of using Disjoint Set Union or DSU crossed my mind and then I was sure to implement my idea using DSU .

Approach ...

View more
Try solving now
2. Construct Binary Tree From Inorder and Preorder Traversal
Easy
10m average time
90% success
0/40
Asked in companies
AppleInfosysSwiggy

You have been given the preorder and inorder traversal of a binary tree. Your task is to construct a binary tree using the given inorder and preorder traversals.


Note:
View more
Problem approach

This was a preety standard question and I had already solved it in platforms like LeetCode and CodeStudio so coding it was not so difficult for me . I first explained my intuition and approach to the interviewer and after that started coding it in my machine . After coding , we discussed its Time and Space Complexity . 

Approach :

The two key observations are:

1) Preor...

View more
Try solving now
3. OS Question

Explain Demand Paging .

Problem approach

Demand paging is a method that loads pages into memory on demand. This method is mostly used in virtual memory.

In this, a page is only brought into memory when a location on that particular page is referenced during execution.

The following steps are generally followed:
1) Attempt to access the page.
2) If the page is valid (in memory) then continue processing instructions ...

View more
04
Round
Medium
Video Call
Duration60 minutes
Interview date12 Jul 2021
Coding problem3

This was a preety intense round as I was grilled more on my System Design concepts but eventually I was able to
asnwers all the questions with some help from the interviewer.

General Tip : While preparing for Facebook Interviews , make sure you read and understand some of the most important features that Facebook incorporates like Graph Search , Adding a friend , Removing a friend , Storing Likes/Dislikes and so on. 
All these features are important to learn because at their core they are nothing but Data Structures used and implemented very elegantly . So before your next Facebook interview , do read these topics and be confident about your LLD as well as HLD skills.

1. System Design Question

How does Facebook store likes/dislikes ?

Problem approach

Approach :
1) We can keep one counter variable which counts the overall likes in that same document where the post's data is present.
2) And store the details/uids of people who liked it in different documents( this way, when we tap on details, then only we'll need to fetch these docs) and, we can setup a cloud func whch updates that counter whenever someone likes/dislikes.
3) To check...

View more
2. System Design Question

How does Facebook implement graph search ?

Problem approach

Answer :

1) Facebook graph search, can be considered as a complex graph with entities like people, pages, photos and videos, while the edges are relationships among all of these entities.
2) Unicorn- standard inverted index system optimized for the needs of Facebook is used for having all the information on the main memory so the query processing doesn't involve any disk access.
3)...

View more
3. System Design Question

How does Facebook Chat works ?

Problem approach

I was asked to answer this question w.r.t 2 very important aspects on how a chat system becomes more engaging to
its users.

Answer :

Real-time messaging :

1) The method FB chooses to get text from one user to another involves loading an iframe on each Facebook page,
and having that iframe’s Javascript make an HTTP GET request over a persistent connection that doesn’t ...

View more
Start a Discussion
Similar interview experiences
company logo
SWE Intern
2 rounds | 5 problems
Interviewed by Facebook
866 views
0 comments
0 upvotes
company logo
SDE - Intern
2 rounds | 3 problems
Interviewed by Facebook
1128 views
0 comments
0 upvotes
company logo
SDE - 1
5 rounds | 10 problems
Interviewed by Facebook
504 views
0 comments
0 upvotes
company logo
SDE - 1
4 rounds | 8 problems
Interviewed by Facebook
528 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
97236 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
45397 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
28416 views
6 comments
0 upvotes