Linked Lists Interview Questions
- 0of 0 votes
AnswersQ 4. You are given a binary tree, and you have to return list of lists of node. where same level nodes should be in the same list, nodes are in opositive order in next list from the previous list
Ex:4 / \ 3 5 / \ \ 1 10 -4
Output would be
- sonesh April 28, 2017 in United States
[[4], [5, 3], [1, 10, -4]]
Desigred Complexity : O(N) + O(N).| Report Duplicate | Flag | PURGE
Hitachi Data Systems Software Engineer / Developer Linked Lists Stacks Trees and Graphs - 0of 0 votes
AnswersQ 3. You are given a LinkedList and a number K. You have to reverse it in the groups of K
- sonesh April 28, 2017 in United States
Ex :
[1] -> [2] -> [3] -> [4] -> [5] -> null, K = 3
output: [3] -> [2] -> [1] -> [5] -> [4] -> null
Desired Complexity: O(n) + O(1)| Report Duplicate | Flag | PURGE
Hitachi Data Systems Software Engineer / Developer Linked Lists - 0of 0 votes
AnswersFind the given doubly linked list is palindrome or not.
- kumar February 19, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Linked Lists - 0of 0 votes
AnswersGiven two linked lists find if they are making a shape of 'Y' or a shape of 'V'.
- santakdalai90 December 20, 2016 in India| Report Duplicate | Flag | PURGE
EFI Software Engineer Linked Lists - 0of 0 votes
AnswersGiven a singly linked list of integers, write a function in java that returns true if the given list is palindrome, else returns false
- mh4wt@virginia.edu December 18, 2016 in United States| Report Duplicate | Flag | PURGE
Microsoft Intern Java Linked Lists - 0of 0 votes
AnswersImplement a linked list and all its basic operations (add, delete, remove and insert)
- JP Ventura November 07, 2016 in Brazil| Report Duplicate | Flag | PURGE
Motorola Android Engineer Linked Lists - 0of 0 votes
AnswersMerge two sorted singly linked lists into one sorted singly linked list. Allocate no extra node.
- Saurabh Singhal January 16, 2016 in India| Report Duplicate | Flag | PURGE
Arista Networks Software Engineer Data Structures Linked Lists - 0of 0 votes
AnswersGiven a linked list which in addition to the 'next' pointer has another valid pointer to a random node in the string, write a function to copy the linked list.
- sln October 01, 2015 in United States| Report Duplicate | Flag | PURGE
Tintri Member Technical Staff Linked Lists - -8of 10 votes
Answers/**
- sunil.sebastian September 01, 2015 in United States
You have list,which contains a DS(Data Structure) which have a list and a value (basically a list of list).
You need to write an iterator such that it will iterate over the numbers/integers whenever a .next() is called
1->2->3->4
|
6---->7------------->10
| |
8->9 11->12
Output
1 .next() -> 1
2..next() -> 6
3..next() ->7
4..next() ->8
5..next() ->9
6..next() ->10
7..next() ->11
8..next() ->12
9..next() ->2
10..next() ->3
11..next() ->4
12..next() -> throws Exception
**/| Report Duplicate | Flag | PURGE
Amazon SDE-2 Linked Lists - 0of 0 votes
AnswersInput: two linked lists that have some duplicate nodes
- dana August 03, 2015 in Israel for Application insight
the list node contains a student's info: name, telephone, address. duplication exist if the same name and phone number appears in two different lists or repeat more than ones in the same list.
Output: one lists that contains unique elements, duplications should be removed.| Report Duplicate | Flag | PURGE
Microsoft Linked Lists - 0of 0 votes
AnswersInsert a value into a sorted linked list.
- zsalloum May 01, 2015 in United States
Using C/C++ write a small function (around 5 lines in the body) to insert a value in a sorted linked list. Take into consideration that the list might be empty at first, and the function should cover the cases of insertion at the head and tail...
PS what the interviewer is looking for is the ability to write a small C/C++ code that solves the question and not the algorithm per se which is trivial| Report Duplicate | Flag | PURGE
Microsoft Jr. Software Engineer C C# C++ Linked Lists - -5of 5 votes
AnswersHaving A List of int [1,1,1,3,1,2,1,1,4,1]
- NullVoid December 31, 2014 in India for ERP
Output needed [1,5,6,3,7,2,8,9,4,10]
Note: Need not to change value of 3,2,4| Report Duplicate | Flag | PURGE
N/A Software Engineer / Developer Arrays Java Linked Lists - 0of 2 votes
AnswersReverse last 5 nodes of linkedlist. Please let me know if there is any better way.
E.g.
Input: 1,2,3,4,5,6,7
Output: 1,2,7,6,5,4,3
- chirag272003 December 09, 2014 in United Statespackage com.acct; public class SinglyLinkedListReverseLast5 { public static void main(String[] args) { Node n7 = new Node(7, null); Node n6 = new Node(6, n7); Node n5 = new Node(5, n6); Node n4 = new Node(4, n5); Node n3 = new Node(3, n4); Node n2 = new Node(2, n3); Node n1 = new Node(1, n2); int numberOfNodestoReverse = 5; System.out.println(n1.toString()); reverse(getNthElement(n1, numberOfNodestoReverse+1)); System.out.println(n1.toString()); } public static Node getNthElement(Node head, int n) { Node f_ptr = head; Node s_ptr = head; for (; n > 0; n--) { f_ptr = f_ptr.next; } while (f_ptr != null) { f_ptr = f_ptr.next; s_ptr = s_ptr.next; } System.out.println(s_ptr.toString()); return s_ptr; } public static void reverse(Node head) { Node current = null; Node next; Node first = head; head = head.next; while (head != null) { next = head.next; head.next = current; current = head; head = next; } first.next = current; } } class Node { int value; Node next; Node(int value, Node next) { this.value = value; this.next = next; } public String toString() { String result = value + " "; if (next != null) { result += next.toString(); } return result; } }
| Report Duplicate | Flag | PURGE
Software Engineer / Developer Linked Lists - 4of 6 votes
AnswersWrite a program to implement Double Linked List from Stack with min. complexity.
- Purushotham Kumar October 20, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Intern Data Structures Java Linked Lists Stacks - 0of 0 votes
AnswersMerge two sorted linked list
- LCHammer September 25, 2014 in United States for Advertising| Report Duplicate | Flag | PURGE
Amazon SDE1 Linked Lists - 0of 0 votes
AnswersWhat does an iterator in C++ point to in case of a vector vs. list. Where would it point to if the prior links are deleted in the list? In case of a vector if it points to a specific index, where would it point to if the prior indexes are deleted?
- farzanmoofty August 12, 2014 in United States for Price history| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Arrays C++ Coding Linked Lists - 0of 2 votes
AnswersDesign a system like friend's functionality in facebook. should have all features of facebook's friends functionality. like for each person , he can have any number of friends , he will get suggestions for new firends , showing common friends if we visits any other profile . algo should be scalable , robust .
- gopi.komanduri August 02, 2014 in United States| Report Duplicate | Flag | PURGE
Computer Scientist Algorithm Android Application / UI Design Arrays Bit Manipulation C# C++ Cache Coding Computer Architecture & Low Level Data Mining Data Structures Database Distributed Computing Dynamic Programming Hash Table Java Large Scale Computing Linked Lists Math & Computation Object Oriented Design Problem Solving Sorting SQL Stacks System Design Trees and Graphs XML - 0of 2 votes
AnswersHow to design a multi key hash map ( key count can be dynamic. if there are two keys , initiallly which can be used to find the value , keys can be increased to three as well ex: consider school structure. Intially , consider , student id is key , later , should be searchable even with key name , later with grade.
- gopi.komanduri July 05, 2014 in India| Report Duplicate | Flag | PURGE
Analyst Algorithm Arrays C# C++ Coding Data Structures Dynamic Programming Experience Hash Table Large Scale Computing Linked Lists Problem Solving Sorting Trees and Graphs - 1of 3 votes
AnswersDesign a telephone directory for large ppl (he gave example like design for India). fields will be , first name , last name , number . this should be searchable with first name , last name , number as welll.
- gopi.komanduri July 04, 2014 in India
later added more complexity like do the same for organisation where even it contains designations. so this should be searchable with designations.| Report Duplicate | Flag | PURGE
Analyst Algorithm Arrays C C++ Cache Coding Computer Architecture & Low Level Data Mining Data Structures Dynamic Programming Hash Table Ideas Large Scale Computing Linked Lists Object Oriented Design Problem Solving Trees and Graphs - -1of 1 vote
AnswersWAP , In SLL delete nth node from end.
- croox_shil May 18, 2014 in India| Report Duplicate | Flag | PURGE
Alcatel Lucent Software Engineer / Developer Linked Lists - 0of 4 votes
AnswersGiven a linked list with next and high pointers, populate high pointers to the next higher node, inplace and O(n).
- HardCode May 13, 2014 in India| Report Duplicate | Flag | PURGE
Microsoft Linked Lists - 2of 2 votes
AnswersConsider sorted singly linked list having following nodes
- msgambhir May 12, 2014 in United States
10->30->50->70->NULL
You are given pointer to node 50 and a new node having value 40. Can you inserted node 40 correctly in the list maintaining the ascending order?| Report Duplicate | Flag | PURGE
Qual Ex Software Engineer / Developer Linked Lists - 0of 0 votes
AnswersGiven number k, for Single linked list, skip k nodes and then reverse k nodes, till the end.
- OTR November 23, 2013 in India| Report Duplicate | Flag | PURGE
iLabs Tech Lead Algorithm Linked Lists - -1of 5 votes
AnswersWhat is the difference between an array and linked list?
- unicorn November 16, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Linked Lists - 0of 4 votes
Answers2.Given an integer linked list of which both first half and second half are sorted independently. Write a function to merge the two parts to create one single sorted linked list in place [do not use any extra space].
- Harjit Singh September 27, 2013 in India for TCS
Sample test case:
Input: List 1:1->2->3->4->5->1->2; Output: 1->1->2->2->3->4->5
Input 2: 1->5->7->9->11->2->4->6; Output 2: 1->2->4->5->6->7->9->11
C/C++/Java/C#
struct node
{
int val;
node *next;
}
node* sortList(node* list1) {
}
Java
class Node
{
int val;
Node next;
}
Node sortList(Node list1) {
}| Report Duplicate | Flag | PURGE
Amazon SDE1 Linked Lists - -1of 1 vote
AnswersDelete the repeated elements in a singly linked list in O(n) time complexity without using extra space. Linked list contains elements in unsorted order
- Saurabh Singhal August 22, 2013 in India
P.S. - Sorting is not allowed| Report Duplicate | Flag | PURGE
VMWare Inc Intern Coding Data Structures Linked Lists - 1of 3 votes
AnswersWrite a function to find 5th element from a singly linked List from the end(not from the head) in one pass.
- priti2.jain August 16, 2013 in United States| Report Duplicate | Flag | PURGE
McAfee Applications Developer Linked Lists - 0of 0 votes
Answersreverse the doubly linked list without using extra space
- saran August 10, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Intern Linked Lists - 2of 4 votes
AnswersC program to Delete a node from SLL, in which the last node points to the middle node( in case of even no of nodes, it points to the first middle node) and update the SLL.
- saran August 06, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Program Manager Intern Linked Lists