Skip to content

Instantly share code, notes, and snippets.

@dim4o
Last active September 8, 2019 08:42
Show Gist options
  • Save dim4o/9a450c1a26dd4b8824f5091a1748ce90 to your computer and use it in GitHub Desktop.
Save dim4o/9a450c1a26dd4b8824f5091a1748ce90 to your computer and use it in GitHub Desktop.
interview

Linked list

Problems:

  • Find the middle element of a linked list. Can you do the work with one pass over the list? See here.

  • Reverse a linked list. Can you reverse the list with O(1) space complexity? See here.

  • Given a singly linked list, determine if it is a palindrome. Could you do it in O(n) time and O(1) space? See here.

  • Given a linked list, determine if it has a cycle in it. Can you solve it using O(1) memory? See here.

  • Merge two sorted linked lists. See here.

  • Write a program to find the node at which the intersection of two singly linked lists begins. Can you solve the problem with O(1) space? See here.

Resources:

Trees

Problems:

  • Find the Lowest Common Ancestor of two given nodes in a Binary Tree.

  • Binary Search Tree traversal - inorder, preorer and postorder

  • Serialize and Deserialize a Binary Tree. See this.

  • Binary Heap

  • Prefix tree

    • explained here
    • practice and solution here
  • Segment tree

  • Given a binary tree, determine if it is a valid binary search tree (BST). See here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment