title-img


Find Merge Point of Two Lists

This challenge is part of a tutorial track by MyCodeSchool Given pointers to the head nodes of 2 linked lists that merge together at some point, find the node where the two lists merge. The merge point is where both lists point to the same node, i.e. they reference the same memory location. It is guaranteed that the two head nodes will be different, and neither will be NULL. If the lists share a common node, return that node's data value. Note: After the merge point, both lists will share

View Solution →

Linked Lists: Detect a Cycle

A linked list is said to contain a cycle if any node is visited more than once while traversing the list. For example, in the following graph there is a cycle formed when node 5 points back to node 3. Function Description Complete the function has_cycle in the editor below. It must return a boolean true if the graph contains a cycle, or false. has_cycle has the following parameter(s): head: a pointer to a Node object that points to the head of a linked list. Returns boolean: T

View Solution →

Recursion: Fibonacci Numbers

The Fibonacci Sequence The Fibonacci sequence appears in nature all around us, in the arrangement of seeds in a sunflower and the spiral of a nautilus for example. The Fibonacci sequence begins with fibonacci(0) = 0 and fibonnaci(1) = 1 as its first and second terms. After these first two elements, each subsequent element is equal to the sum of the previous two elements. Programmatically: fibonacci(0) = 0 fibonacci(1) = 1 fibonacci(n) = fibonacci( n - 1 ) + fibonacci( n - 2 )

View Solution →

Recursion: Davis' Staircase

Davis has a number of staircases in his house and he likes to climb each staircase 1, 2, or 3 steps at a time. Being a very precocious child, he wonders how many ways there are to reach the top of the staircase. Given the respective heights for each of the staircases in his house, find and print the number of ways he can climb each staircase, module 10^10 + 7 on a new line. Example n = 5 The staircase has 5 steps. Davis can step on the following sequences of steps: 1 1 1

View Solution →

Crossword Puzzle

A 10 x 10 Crossword grid is provided to you, along with a set of words (or names of places) which need to be filled into the grid. Cells are marked either + or -. Cells marked with a - are to be filled with the word list. The following shows an example crossword from the input crossword grid and the list of words to fit, Function Description Complete the crosswordPuzzle function in the editor below. It should return an array of strings, each representing a row of the finished puzzl

View Solution →