# Kotlin Whiteboard

Jul 28 2020 · Video Course (3 hrs, 5 mins) · Intermediate

Level up your whiteboard interview skills by solving a number of common coding interview questions using Kotlin.

#### Version

- Kotlin 1.3, IntelliJ IDEA 2020.1

## Introduction

Learn about the common developer interview practice of whiteboarding, and see some strategies for preparing for whiteboard interviews.

#### Prerequisites

3:54Understand the prerequisites for following along with the course, and see some resources for learning about data structures and algorithms.

#### Use The Sample Code

4:16See how to create IntelliJ IDEA Kotlin JVM projects that allow you to work with the sample code from the course episodes and how to use the Kotlin playground.

#### Find the Range

10:59Learn about binary search and solve a warm-up question that uses a technique similar to binary search.

## Linear Data Structures

See a review of some of the key properties of linear data structures: arrays, linked lists, stacks, and queues.

Given a linked list, create an extension function on the LinkedList class to print the nodes in reverse order.

Given a linked list, reverse the linked list itself, so that the nodes are linked in the opposite direction.

#### Merge Linked Lists

5:04Create a function that takes two sorted linked lists and merges them into a single sorted linked list.

Given a linked list, create an extension function on the LinkedList class to print the nodes in reverse order, but this time, with no recursion.

#### Next Player

2:36Imagine you’re playing a game of Monopoly with your friends. Create a Monopoly organizer that tells you whose turn it is.

#### Reverse a Queue

3:03Implement a method to reverse the contents of a queue using an extension function.

## Trees

#### Trees

4:04Review the definitions surrounding tree data structures and the properties of a number of tree variants.

#### Tree Height

3:01Given a Binary Tree, write an extension function to find the height of the tree.

Devise a way to serialize a Binary Tree into a list, and a way to deserialize the list back into the same Binary Tree.

#### BST Equality

3:22Add methods to a BinarySearchTree class and BinaryNode class to check whether two BSTs are equal.

#### BST Same Elements

3:32Create a method to checks if one BST contains all of the elements of another BST.

#### Count the Leaves

2:36How many leaf nodes are there in a perfectly balanced Binary Tree of height 3? What about a perfectly balanced Binary Tree of height h?

#### Count the Nodes

2:40How many nodes are there in a perfectly balanced Binary Tree of height 3? What about a perfectly balanced Binary Tree of height h?

## Heaps and Priority Queues

Review the heap and priority queue data structures as well as their properties and applications.

Write a function to find the nth smallest integer in an unsorted array.

#### Sorting by Priority

3:07Use a priority queue to get a list of people on a waitlist by the appropriate priority.

## Basic Sorting

#### Bubble Sort

5:12Review Bubble Sort visually then add Bubble Sort as an extension function on MutableList.

#### Selection Sort

3:34Review Selection Sort visually then add Selection Sort as an extension function on MutableList.

#### Insertion Sort

3:46Review Insertion Sort visually then add Insertion Sort as an extension function on MutableList.

#### Move to the Left

4:19Given a list of Comparable elements, bring all instances of a given value in the list to the right side of the list.

#### Duplicate Finder

4:59Given a list of Comparable elements, return the largest element that’s a duplicate in the list.

#### Manual Reverse

2:03Create a function to reverse a mutable list of elements without relying on any library functions.

## Advanced Sorting

#### Advanced Sorting

2:05Review some of the more advanced sorting algorithms: Merge Sort, Radix Sort, Heap Sort, and Quicksort.

#### Merge Iterables

4:57Write a function that takes two sorted Kotlin iterables and merges them into a single iterable.

Implement a most-significant-digit (MSD) Radix Sort, also called lexicographical sorting.

#### Fewest Comparisons

1:04When performing a Heap Sort in ascending order, choose which of two starting arrays require the fewest comparisons.

#### Descending Sort

1:57Use Heap Sort to sort an array in descending order instead of ascending order.

#### Iterative Quicksort

4:10The Quicksort algorithm is typically implemented using recursion. Can you implement it iteratively?

## Graphs

#### Graphs

2:41Review the definition of graphs as well as some of the properties of graphs and their implementation.

Write a method to count the number of paths between two vertices in a directed graph.

#### How Many Nodes

2:22Determine the maximum number of items ever in the queue used to perform a breadth-first traversal on a given undirected graph.

#### DFS or BFS

0:50For a given graph, determine which traversal (DFS or BFS) is better for discovering if a path exists between certain nodes.

## Who is this for?

Kotlin developers preparing for job interviews or looking to refresh their coding interview skills.

## Covered concepts

- Binary search
- Linear data structures: linked lists, stacks, and queues
- Trees, Binary Trees, BSTs, and AVL Trees
- Heaps and Priority Queues
- Basic sorting algorithms
- Merge Sort, Radix Sort, Heap Sort, and Quicksort
- Graphs, BFS, and DFS

## Comments