Linked Lists - Push & BuildOneTwoThree
Description:
Linked Lists - Push & BuildOneTwoThree
Write push() and buildOneTwoThree() functions to easily update and initialize linked lists. Try to use the push() function within your buildOneTwoThree() function.
Here's an example of push() usage:
var chained = null
chained = push(chained, 3)
chained = push(chained, 2)
chained = push(chained, 1)
push(chained, 8) === 8 -> 1 -> 2 -> 3 -> null
The push function accepts head and data parameters, where head is either a node object or null/None/nil. Your push implementation should be able to create a new linked list/node when head is null/None/nil.
The buildOneTwoThree function should create and return a linked list with three nodes: 1 -> 2 -> 3 -> null
Related Kata in order of expected completion (increasing difficulty):
Linked Lists - Push & BuildOneTwoThree
Linked Lists - Length & Count
Linked Lists - Get Nth Node
Linked Lists - Insert Nth Node
Linked Lists - Sorted Insert
Linked Lists - Insert Sort
Linked Lists - Append
Linked Lists - Remove Duplicates
Linked Lists - Move Node
Linked Lists - Move Node In-place
Linked Lists - Alternating Split
Linked Lists - Front Back Split
Linked Lists - Shuffle Merge
Linked Lists - Sorted Merge
Linked Lists - Merge Sort
Linked Lists - Sorted Intersect
Linked Lists - Iterative Reverse
Linked Lists - Recursive Reverse
Inspired by Stanford Professor Nick Parlante's excellent Linked List teachings.
I'm aware that there are better ways to create linked lists (class methods, reference pointers, etc.), but not all languages have the same features. I'd like to keep the basic API consistent between language translations for this kata.
Similar Kata:
Stats:
Created | Aug 2, 2015 |
Published | Aug 2, 2015 |
Warriors Trained | 16787 |
Total Skips | 2763 |
Total Code Submissions | 19057 |
Total Times Completed | 6424 |
JavaScript Completions | 2403 |
Python Completions | 2400 |
Ruby Completions | 351 |
CoffeeScript Completions | 32 |
PHP Completions | 184 |
Swift Completions | 614 |
Java Completions | 445 |
C# Completions | 286 |
λ Calculus Completions | 18 |
Total Stars | 346 |
% of votes with a positive feedback rating | 82% of 889 |
Total "Very Satisfied" Votes | 638 |
Total "Somewhat Satisfied" Votes | 174 |
Total "Not Satisfied" Votes | 77 |