Tags » Linked List

Interview Question - Tail

In my hiatus, I finished my last semester at Georgia Tech and began my job search. I had an offer starting the semester, so I wanted to explore my options before the deadline near the end of the year. 767 more words

Development

Reorder List

Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…

You must do this in-place without altering the nodes’ values.

For example,
Given {1,2,3,4} 135 more words

Leetcode

Merge k Sorted Lists

Analysis:

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.

  1. use a heap and put all the nodes in the heap;
  2. 131 more words
Leetcode

Sort List

Sort a linked list in O(n log n) time using constant space complexity.

Analysis:

  1. here I use recursion, so the space complexity is O(long(n));
  2. use slow and fast pointer to find the mid of the list.
  3. 146 more words
Leetcode

Rotate List

Given a list, rotate the list to the right by k places, where k is non-negative.

For example:
Given 1->2->3->4->5->NULL and k = 2, 106 more words

Leetcode

Adding object at the specified Index in the Singly Linked List

// Method to add the given object at a specified Index of the Singly Linked List

public object Add(int index, object o)
{
if (index < 0) 47 more words

Technical