LinkedIn interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

LinkedIn
upvote
share-icon
3 rounds | 9 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 6 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: Referral
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
Medium
Face to Face
Duration60 minutes
Interview date25 May 2015
Coding problem3

Technical round with questions based on DSA. Also, there was a discussion on my BTP project.

1. Longest Palindromic Subsequence

Hard
45m average time
50% success
0/120
Asked in companies
MicrosoftQualcommHike

You have been given a string ‘A’ consisting of lower case English letters. Your task is to find the length of the longest palindromic subsequence in ‘A’.

A subsequence is a sequence generated from a string after deleting some or no characters of the string without changing the order of the remaining string characters. (i.e. “ace” is a subsequence of “abcde” while “aec” is not).

A string is said to be palindrome if the reverse of the string is the same as the actual string. For example, “abba” is a palindrome, but “abbc” is not a palindrome.

Problem approach

The brute force solution is based on the idea that if the two ends of a string are the same, then they must be included in the longest palindrome subsequence. Otherwise, both ends cannot be included in the longest palindrome subsequence. So, recursion can be used here. 
Time Complexity of this approach would be exponential. 

This solution can be optimized using dynamic programming. 
Let dp[l][r] denote the length of the longest palindromic subsequence of s[l..r].
There are 2 options:
o If s[l] == s[r] then dp[l][r] = dp[l+1][r-1] + 2
o Elif s[l] != s[r] then dp[l][r] = max(dp[l+1][r], dp[l][r-1]).
Then dp[0][n-1] is our result.

Try solving now

2. Convert A Given Binary Tree To Doubly Linked List

Moderate
15m average time
80% success
0/80
Asked in companies
FacebookMicrosoftAmazon

Given a Binary Tree, convert this binary tree to a Doubly Linked List.

A Binary Tree (BT) is a data structure in which each node has at most two children.

A Doubly Linked List contains a previous pointer, along with the next pointer and data.

The order of nodes in Doubly Linked List must be the same as Inorder of the given Binary Tree.

The doubly linked list should be returned by taking the next pointer as right and the previous pointer as left.

You need to return the head of the Doubly Linked List.

For the given binary tree :

alt txt

You need to return the head to the doubly linked list.
The doubly linked list would be: 1 2 3 4 5 and can be represented as:

alt txt

Problem approach

The idea is to traverse all the leaves and connect them by changing their left and right pointers. We also need to remove them from the Binary Tree by changing left or right pointers in parent nodes. 
One way to solve this is to add the leaves at the beginning of the current linked list and update the head of the list using the pointer to head pointer. Since we insert at the beginning, we need to process leaves in reverse order. For reverse order, we first traverse the right subtree, then the left subtree. We use return values to update left or right pointers in parent nodes.

Try solving now

3. Palindrome Permutation

Easy
15m average time
85% success
0/40
Asked in companies
LinkedInAmazonWalmart

You are given a string 'S', check if there exists any permutation of the given string that is a palindrome.

Note :

1. A palindrome is a word or phrase that reads the same from forward and backward e.g. “aba”, it reads the same from forward and backward.
2. A permutation is a rearrangement of letters.
3. The palindrome does not need to be limited to just dictionary words.

Example :

Given string S : aab
The output should be "True" as "aba" (permutation of string S) is a palindrome. 
Problem approach

The brute force solution is to run two loops, the outer loop picks all characters one by one, the inner loop counts the number of occurrences of the picked character. We keep track of odd counts. Time complexity of this solution is O(n2). 
We can do it in O(n) time using a count array. 
Steps : 
1. Create a count array of alphabet size which is typically 256. Initialize all values of count array as 0.
2. Traverse the given string and increment count of every character.
3. Traverse the count array and if the count array has more than one odd values, return false. Otherwise, return true.

Try solving now
02
Round
Medium
Face to Face
Duration60 minutes
Interview date25 May 2015
Coding problem3

Technical interview round where the interviewer asked me questions based on DSA , algorithms and my project. Large set of questions pertaining to DBMS.

1. Serialize/Deserialize The Binary Tree

Hard
15m average time
85% success
0/120
Asked in companies
eBayAppleUber

You have been given a binary tree of integers. You are supposed to serialize and deserialize (refer to notes) the given binary tree.


You can choose any algorithm to serialize/deserialize the given binary tree. You only have to ensure that the serialized string can be deserialized to the original binary tree.


Note :
Serialization is the process of translating a data structure or object state into a format that can be stored or transmitted (for example, across a computer network) and reconstructed later. The opposite operation, that is, extracting a data structure from stored information, is deserialization.
Problem approach

Recursion can be used here. Once the parent node is processed, make recursive calls for the children node. 
For serializing the tree into a list : 
• If node is null, store -1 in list and return
• Store the data at current node in list.
• Call function recursively for left and right subtrees.
• Return the list.
For deserializing the list into a tree : 
• If there are no more elements in list, return null.
• Create new node for storing current element.
• Call function recursively for left and right subtrees.
• Return the tree.

Try solving now

2. Shuffle Two Strings

Hard
50m average time
50% success
0/120
Asked in companies
GoogleTata Consultancy Services (TCS)Accenture

You are given three strings “A”, “B” and “C”. Your task is to check whether “C” is formed by an interleaving of A and B. C is said to be interleaving “A” and “B”, if the length of “C” is equal to the sum of the length of A and length of B, all the characters of “A” and “B” are present in “C”, and the order of all these characters remains the same in all three strings.

For Example:
If A = “aab”, B = “abc”, C = “aaabbc”
Here C is an interleaving string of A and B. Because C contains all the characters of A and B and the order of all these characters is also the same in all three strings.

interleaving

If A = “abc”, B = “def”, C = “abcdefg”
Here C is not an interleaving string of A and B as neither A nor B contains the character ‘g’.
Problem approach

The idea is to start from the last element, swap it with a randomly selected element from the whole array (including last). Now consider the array from 0 to n-2 (size reduced by 1), and repeat the process till we hit the first element. 
Algorithm : 

To shuffle an array a of n elements (indices 0..n-1):
for i from n - 1 down to 1 do
j = random integer with 0 <= j <= i
exchange a[j] and a[i]

Time Complexity: O(n), assuming that the function rand() takes O(1) time.
Auxiliary Space: O(1)

Try solving now

3. Technical Question

What is rolling hash? Any application of rolling hash?

Problem approach

A rolling hash is a hash function where the input is hashed in a window that moves through the input.
A few hash functions allow a rolling hash to be computed very quickly—the new hash value is rapidly calculated given only the old hash value, the old value removed from the window, and the new value added to the window—similar to the way a moving average function can be computed much more quickly than other low-pass filters.
One of the main applications is the Rabin–Karp string search algorithm, which uses the rolling hash.

03
Round
Medium
Face to Face
Duration60 minutes
Interview date25 May 2015
Coding problem3

This was a design round where I was grilled on my internship , projects and some new design questions were also asked.
Q1. Design a work flow model of the entire work done in your internship.
Q2. Design a workflow model of any one of the projects you did.

1. System Design Question

A map based design for implementing a code to check for isomorphic words in a file

Problem approach

Tip 1: Mapping of current characters can be stored in a map. 
To check for two strings to be isomorphic using a map :
1) If lengths of str1 and str2 are not same, return false.
2) Do following for every character in str1 and str2
a) If this character is seen first time in str1, then current of str2 must have not appeared before.
(i) If current character of str2 is seen, return false. Mark current character of str2 as visited.
(ii) Store mapping of current characters.
b) Else check if previous occurrence of str1[i] mapped to same character.

2. System Design Question

You need to present a ppt to say N users who are viewing it live in their browsers. What you have is a web page where the ppt is opened and has say two buttons : next and previous. You need to design basically what will happen / how will pressing of the buttons reflect a change across all the users.( He wanted something as to how the DNS on processing the next request would change the URL and convey it to all connected users)

Problem approach

Tip 1:Before you jump into the solution always clarify all the assumptions you’re making at the beginning of the interview. Ask questions to identify the scope of the system. This will clear the initial doubt, and you will get to know what are the specific detail interviewer wants to consider in this service.
Tip 2 : Design your structure and functions according to the requirements and try to convey your thoughts properly to the interviewer so that you do not mess up while implementing the idea .

3. Design a stack that supports getMin() in O(1) time and O(1) extra space

Moderate
15m average time
85% success
0/80
Asked in companies
ShareChatGrofersGroww

Create a stack data structure that allows operations such as push (adding an element), pop (removing the top element), top (retrieving the top element), and also provides a way to retrieve the minimum element in constant time.


Implement the following public functions :

1. push(data) :
This function should take one argument of type integer. It pushes the element into the stack and returns nothing.

2. pop() :
It pops the element from the top of the stack and returns nothing.

3. top() :
It returns the element being kept at the top of the stack.

4.  getMin() :
It returns the smallest element present in the stack.
Operations Performed on the Stack:
Query-1(Denoted by an integer 1): Pushes integer data to the stack. (push function)

Query-2(Denoted by an integer 2): Pops the data kept at the top of the stack. (pop function)

Query-3(Denoted by an integer 3): Fetches and returns the data being kept at the top of the stack. (top function)

Query-4(Denoted by an integer 4): Returns the smallest element present in the stack. (getMin() function)
Problem approach

Use two stacks: one to store actual stack elements and the other as an auxiliary stack to store minimum values. 
The idea is to do push() and pop() operations in such a way that the top of the auxiliary stack is always the minimum. 

Push(int x) // inserts an element x to Special Stack 
1) push x to the first stack (the stack with actual elements) 
2) compare x with the top element of the second stack (the auxiliary stack). Let the top element be y. 
…..a) If x < y then push x to the auxiliary stack. 
…..b) If x > y then push y to the auxiliary stack.
int Pop() // removes an element from Special Stack and return the removed element 
1) pop the top element from the auxiliary stack. 
2) pop the top element from the actual stack and return it.

int getMin() // returns the minimum element from Special Stack 
1) Return the top element of the auxiliary stack.

Try solving now

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

Which operator is used for exponentiation in Python?

Choose another skill to practice
Similar interview experiences
company logo
SDE - 1
3 rounds | 5 problems
Interviewed by LinkedIn
889 views
0 comments
0 upvotes
company logo
SDE - 1
1 rounds | 3 problems
Interviewed by LinkedIn
773 views
0 comments
0 upvotes
company logo
SDE - 1
2 rounds | 4 problems
Interviewed by LinkedIn
912 views
0 comments
0 upvotes
company logo
SDE - 1
2 rounds | 4 problems
Interviewed by LinkedIn
906 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
1 rounds | 2 problems
Interviewed by Tata Consultancy Services (TCS)
0 views
0 comments
0 upvotes
company logo
SDE - 1
3 rounds | 4 problems
Interviewed by Tata Consultancy Services (TCS)
5947 views
0 comments
0 upvotes
company logo
SDE - 1
2 rounds | 3 problems
Interviewed by BNY Mellon
5199 views
3 comments
0 upvotes