Linkedin Interview Questions
- 0of 0 votes
AnswersImplement a TwoSum interface that has 2 methods: Store and Test. Store adds an integer to an internal data store and Test checks if an integer passed to Test is the sum of any two integers in the internal data store. Once you provide an answer interviewer will ask the O complexity of the solution and ask you to optimize it.
I provided 2 solutions, one with O(n-square) and another O(n). However the O(n) solution used 2 internal data stores. I was asked to preserve O(n) but not use the second internal store
- palak.chokshi July 01, 2016 in United Statespublic interface TwoSum { /* * Stores input in an internal data structure. */ public void Store(int input); /* * Returns true if there is any pair of numbers in the internal data structure which * have sum val, and false otherwise. * For example, if the numbers 1, -2, 3, and 6 had been stored, * the method should return true for 4, -1, and 9, but false for 10, 5, and 0 */ public bool Test(int val); } public class TwoSumImpl : TwoSum { private List<int> _store = new List<int>(); private List<int> _sums = new List<int>(); public void TwoSumImp() { } //-3,-2,3,5,7 //-5,0,1,-2,-3,8, public void Store(int input) { if(!_store.Contains(input)) { _store.Add(input); } } public bool Test(int val) { for(int i=0; i<_store.Count;i++) { if(_store[i] < 0) //store[i] is negative { diff = val + Math.Abs(_store[i]); if(_store.Contains(diff)) { return true; } } else //store[i] is positive { diff = val - _store[i]; if(_store.Contains(diff)) { return true; } return false; } } }
| Report Duplicate | Flag | PURGE
Linkedin Senior Software Development Engineer Algorithm - 1of 1 vote
AnswersWrite a program that takes an integer and prints out all ways to multiply smaller integers that equal the original number, without repeating sets of factors. In other words, if your output contains 4 * 3, you should not print out 3 * 4 again as that would be a repeating set. Note that this is not asking for prime factorization only. Also, you can assume that the input integers are reasonable in size; correctness is more important than efficiency.
- xankar June 07, 2016 in United States
Eg: PrintFactors(12) 12 * 1 6 * 2 4 * 3 3 * 2 * 2| Report Duplicate | Flag | PURGE
Linkedin Software Developer Algorithm - 0of 0 votes
AnswersWrite a function that takes a string representing as value in roman numbers and returns it as an integer.
- joey April 28, 2016 in United StatesImplement the following /** * * romanNumber("III") = 3 * romanNumber("IV") = 4 */ int romanNumber(String roman) { // ... }
| Report Duplicate | Flag | PURGE
Linkedin Software Developer Algorithm - 0of 0 votes
AnswersWrite a function that takes a number and returns the square root
- joey April 28, 2016 in United StatesImplement the following double sqrt(double d) { // ... }
| Report Duplicate | Flag | PURGE
Linkedin Software Developer Algorithm - 0of 0 votes
AnswersGiven a stream of numbers write a program that computes sum of pair of numbers. There should be two methods store and IsNumberPresent. The store should store the numbers and IsNumberPresent should check if the number is present in the computed sums.
- anonymous February 16, 2016 in India| Report Duplicate | Flag | PURGE
Linkedin Senior Software Development Engineer Algorithm - 0of 0 votes
AnswersImplement following interface so that multi-put is atomic. Expect multiple producers and consumers inserting to and extracting from this queue implementation.
- scgupta January 30, 2016 in India
/**
* threadSafe bounded blocking queue implementation. Expected to be used in a
* Producer->Consumer pattern
*/
public interface MultiPutBlockingBoundedQueue<E> {
/**
* Sets the capacity of the buffer. Can be called only once. If called more
* than once or if the passed capacity is <= 0, throw an exception.
*/
public void init(int capacity) throws Exception;
/**
* Get the next item from the queue throws Exception if not initialized
*/
public E get() throws Exception;
/**
* Put the item to the tail of the queue. throws Exception if not
* initialized
*/
public void put(E obj) throws Exception;
/**
* Put the list of items in an atomic manner. The list can be more than the
* capacity throws Exception if not initialized
*/
public void multiput(List<E> objs) throws Exception;
}| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Java - 0of 0 votes
AnswersFind the length of a maximum palindrome subset in an array. For example: in 1, 2, 4, 1 the maximum palindrome subset is 1, 2, 1 and the answer is 3
- dlyakolesa January 27, 2016 in United States| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Algorithm - 0of 0 votes
AnswersImplement a function which modifies a binary tree so that the output is the tree that is a mirror of an input tree
- dlyakolesa January 27, 2016 in United States| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Algorithm - 0of 0 votes
Answer1) What is transaction
- dlyakolesa January 27, 2016 in United States| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Computer Science - 29of 29 votes
AnswersGiven string say ABCGRETCABCG and substring length let us take length as 3, find the count of possible substrings, for example in above string ABC => 2 and BCG => 2 , where CGR and other 3 word length substrings has a count of 1.
- softwaregeek December 08, 2015 in India for Not known| Report Duplicate | Flag | PURGE
Linkedin Software Developer Algorithm - 0of 0 votes
AnswersGiven a set of numbers find if a triplet can form a triangle a+b > c , b+c > a and c+a > b. The result to display all possible combinations of triplets. [ 10 5 3 4 7 1] [5,3,4 ] is one possible triplet and there can be many more.
- softwaregeek December 08, 2015 in India for Not known| Report Duplicate | Flag | PURGE
Linkedin Software Developer Algorithm - 0of 0 votes
AnswersFor typical word ladder problem to get the shortest path, BFS has complexity exponential to the word string length. How to optimize?
- jiangok2006 November 28, 2015 in United States| Report Duplicate | Flag | PURGE
Linkedin Algorithm - 2of 2 votes
AnswersEvaluate the value of an expression given in Reverse Polish notation
- varun.venu September 22, 2015 in United States| Report Duplicate | Flag | PURGE
Linkedin Senior Software Development Engineer Coding - 4of 4 votes
AnswersThis question was asked in the Technical Design round.
- varun.venu September 22, 2015 in United States
How would you design a system to provide the top trending topcis in the last 5m/1hour/24hours
The most trending topic should appear first
A topic is said to be trending if it is shared the most. We are talking about a typical multi user environment (something like twitter, facebook).| Report Duplicate | Flag | PURGE
Linkedin Senior Software Development Engineer System Design - 1of 1 vote
AnswersThis question was asked in the first coding round on-site.
- varun.venu September 22, 2015 in United States
Give two sorted lists List<Integer> a and List<Integer> b.
Find
the Union of these two lists -> the union list should also be sorted
the Intersection of these two lists -> Intersection list should also be sorted.| Report Duplicate | Flag | PURGE
Linkedin Senior Software Development Engineer Coding - 1of 1 vote
AnswersThose who've attended on-site interview with LinkedIn might know that there are 2 rounds of coding interviews. This question was asked in my 2nd round of coding interview,
- varun.venu September 22, 2015 in United States
Given two valid dictionary words of same length, write a function which returns the minimum number of steps to go from the first to the second word.
You can change only one character at a time. Also, the word formed at every step should be a valid dictionary word.
Eg: Provide minimum steps to go from 'cat' to 'dog'
cat -> bat -> bet -> bot -> bog -> dog
Ans: 5| Report Duplicate | Flag | PURGE
Linkedin Senior Software Development Engineer Coding - 0of 0 votes
AnswersGiven a collection of pair representing intervals write a function which inserts new interval into collection and merges overlapping intervals.
- Eugene June 17, 2015 in United States
Example:
[-10, -1], [0,2], [4,10]
insert [-5, 1]
output: [-10, 2], [4, 10]| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Algorithm - 2of 2 votes
AnswersShuffle a given array such that each position is equally likely.
- xmlprgrm June 15, 2015 in United States| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Algorithm - 0of 0 votes
Answers/*
- aj June 02, 2015 in United States
Tree:
1
/ \
3 5
/ \ \
2 4 7
/ \ \
9 6 8
==========
Expected Output:
1
35
247
968
*/
class TreePrinter {
static class Node {
int value;
Node left;
Node right;
public Node(int value, Node left, Node right) {
this.value = value;
this.left = left;
this.right = right;
}
}
public void printTree(Node root) {
// implementation here
}| Report Duplicate | Flag | PURGE
Linkedin Applications Developer Coding - 0of 0 votes
Answers/*Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die. Given a flowerbed (represented as an array containing booleans), return if a given number of new flowers can be planted in it without violating the no-adjacent-flowers rule
- aj June 02, 2015 in United States
Sample inputs
Input: 1,0,0,0,0,0,1,0,0
3 => true
4 => false
Input: 1,0,0,1,0,0,1,0,0
1 => true
2 => false
input: 0
1 => true
2 => false */
public boolean canPlaceFlowers(List<Boolean> flowerbed, int numberToPlace) {
// Implementation here
}| Report Duplicate | Flag | PURGE
Linkedin Applications Developer Coding - 1of 1 vote
Answers
- sakshisharma April 03, 2015 in United Statespublic interface Triangle { /** * Three segments of lengths A, B, C form a triangle iff * * A + B > C * B + C > A * A + C > B * * e.g. * 6, 4, 5 can form a triangle * 10, 2, 7 can't * * Given a list of segments lengths algorithm should find at least one triplet of segments that form a triangle (if any). * * Method should return an array of either: * - 3 elements: segments that form a triangle (i.e. satisfy the condition above) * - empty array if there are no such segments */ int[] getTriangleSides(int[] segments); }
| Report Duplicate | Flag | PURGE
Linkedin Software Developer Algorithm - 0of 0 votes
AnswersGiven a list of child->parent relationships, build a binary tree out of it. All the element Ids inside the tree are unique.
- prashanti1902 March 18, 2015 in United States
Example:
Given the following relationships:
Child Parent IsLeft
15 20 true
19 80 true
17 20 false
16 80 false
80 50 false
50 null false
20 50 true
You should return the following tree:
50
/ \
20 80
/ \ / \
15 17 19 16
Function Signature
/**
* Represents a pair relation between one parent node and one child node inside a binary tree
* If the _parent is null, it represents the ROOT node
*/
public class Relation {
public Integer _parent;
public Integer _child;
public boolean _isLeft;
}
/**
* Represents a single Node inside a binary tree
*/
public class Node {
public Integer _id;
public Node _left;
public Node _right;
}
/**
* Implement a method to build a tree from a list of parent-child relationships
* And return the root Node of the tree
*/
public Node buildTree (List<Relation> data)
{
}| Report Duplicate | Flag | PURGE
Linkedin Testing / Quality Assurance Algorithm - 0of 0 votes
AnswersImplement Two Sum Interface -
- javaspring7 March 13, 2015 in United Statespublic interface TwoSum { /** * Stores @param input in an internal data structure. */ void store(int input); /** * Returns true if there is any pair of numbers in the internal data structure which * have sum @param val, and false otherwise. * For example, if the numbers 1, -2, 3, and 6 had been stored, * the method should return true for 4, -1, and 9, but false for 10, 5, and 0 */ boolean test(int val); }
| Report Duplicate | Flag | PURGE
Linkedin Algorithm - 6of 6 votes
AnswerPhone Interview with Collabedit.
- Sagar Shah February 11, 2015 in United States
/** Compute the value of an expression in Reverse Polish Notation. Supported operators are "+", "-", "*" and "/".
* Reverse Polish is a postfix mathematical notation in which each operator immediately follows its operands.
* Each operand may be a number or another expression.
* For example, 3 + 4 in Reverse Polish is 3 4 + and 2 * (4 + 1) would be written as 4 1 + 2 * or 2 4 1 + *
*
* @param ops a sequence of numbers and operators, in Reverse Polish Notation
* @return the result of the computation
* @throws IllegalArgumentException ops don't represent a well-formed RPN expression
* @throws ArithmeticException the computation generates an arithmetic error, such as dividing by zero
*
* <p>Some sample ops and their results:
* ["4", "1", "+", "2.5", "*"] -> ((4 + 1) * 2.5) -> 12.5
* ["5", "80", "40", "/", "+"] -> (5 + (80 / 40)) -> 7
*/| Report Duplicate | Flag | PURGE
Linkedin Android Engineer Data Structures - 3of 3 votes
AnswersFind a given element in sorted array.
- tazo February 10, 2015 in United States
arr= [1, 2, 3, 4, 5, 6]
follow up: If the sorted array is shifted left by unknown number, modify existing binary search to find a element in modified array
arr = [4, 5, 6, 1, 2, 3]| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Arrays - 0of 0 votes
AnswersWrite a function to determine if a string is a number without using any built-in function.
- Raul Rivero January 13, 2015 in United Statespublic bool IsNumber(string num) { }
| Report Duplicate | Flag | PURGE
Linkedin Front-end Software Engineer Algorithm - 0of 0 votes
AnswersA server receives requests from different clients...each client send a Runnable job and time on which this job should be run. Write a java program that would accept these jobs and run each job at the required time. Hint: the solution should have a job priority queue to hold the jobs and it should be multithreaded. One thread should accept the tasks, the other one should run the jobs. Also conditions and signalling will be used
- koks2000 December 09, 2014 in United States| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Intern Java Threads - 1of 1 vote
AnswersGiven a array of positive integers, find all possible triangle triplets that can be formed from this array.
- Aspire November 25, 2014 in United States
eg: 9 8 10 7
ans: 9 8 10, 9 8 7, 9 10 7, 7 8 10
Note : array not sorted, there is no limit on the array length| Report Duplicate | Flag | PURGE
Linkedin SDE1 Algorithm - 0of 0 votes
AnswersWrite an function to judge whether the input String is a number?
- fenghanlu November 11, 2014 in United States
For example: "-3.3425","80.0", both of them are number| Report Duplicate | Flag | PURGE
Linkedin Developer Program Engineer Algorithm - 1of 1 vote
Answers/* Write a function to compute the maximum length palindromic sub-sequence of an array.
- qik21 November 06, 2014 in United States
A palindrome is a sequence which is equal to its reverse.
A sub-sequence of an array is a sequence which can be constructed by removing elements of the array.
Ex: Given [4,1,2,3,4,5,6,5,4,3,4,4,4,4,4,4,4] should return 10 (all 4's) */
class Interview {
public static int maxLengthPalindrome(int[] values) {
//ur implementation here
}| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer