Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 1.44 KB

more_interview_practice.md

File metadata and controls

49 lines (34 loc) · 1.44 KB

More Technical Interview Practice

Problems

Reverse an Array

Silver

Write a function that takes an array of numbers a, and returns an array with the elements of a in reversed order. Use only Array#length and array indices for array access. (In other words, no Array#reverse, Array#<<, Array#pop, etc!)

Gold

Reverse the array in O(1) (constant) space, that is, don't use more than a fixed number of additional variables, regardless of the length of a.

Linked List Operations

Append List

Write a list_append function, that takes a linked list l1 and a linked list l2 and returns a linked list with l2 appended to the end of l1. (Think l1 + l2).

Prepend List

Write a list_prepend function, that takes a linked list l1 and a linked list l2 and returns a linked list with l2 prepended to the beginning of l1. (Think l2 + l1).

Insert List After Element

Write a method insert_after that takes a linked list l1, a linked list l2, and a value v, and inserts the list l2 after the first occurance of the value v in l1.

Insert List Before Element

Write a method insert_before that takes a linked list l1, a linked list l2, and a value v, and inserts the list l2 before the first occurance of the value v in l1.