Linked Lists - Append
Description:
Linked Lists - Append
Write an Append() function which appends one linked list to another. The head of the resulting list should be returned.
var listA = 1 -> 2 -> 3 -> null
var listB = 4 -> 5 -> 6 -> null
append(listA, listB) === 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> null
If both listA and listB are null/NULL/None/nil, return null/NULL/None/nil. If one list is null/NULL/None/nil and the other is not, simply return the non-null/NULL/None/nil list.
The push() and buildOneTwoThree() (build_one_two_three()
in PHP and ruby) functions need not be redefined. The Node
class is also predefined for you in PHP.
/* PHP Only */
class Node {
public $data, $next;
public function __construct($data, $next = NULL) {
$this->data = $data;
$this->next = $next;
}
}
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.
Similar Kata:
Stats:
Created | Aug 17, 2015 |
Published | Aug 19, 2015 |
Warriors Trained | 7201 |
Total Skips | 812 |
Total Code Submissions | 9853 |
Total Times Completed | 3130 |
JavaScript Completions | 1202 |
Python Completions | 1138 |
CoffeeScript Completions | 19 |
Swift Completions | 351 |
PHP Completions | 48 |
Ruby Completions | 86 |
Java Completions | 428 |
Total Stars | 99 |
% of votes with a positive feedback rating | 88% of 508 |
Total "Very Satisfied" Votes | 408 |
Total "Somewhat Satisfied" Votes | 80 |
Total "Not Satisfied" Votes | 20 |