Linked Lists - Length & Count
Description:
Linked Lists - Length & Count
Implement length
to count the number of nodes in a linked list.
length(null) => 0
length(1 -> 2 -> 3 -> null) => 3
Implement Count() to count the occurrences of an integer in a linked list.
count(null, 1) => 0
count(1 -> 2 -> 3 -> null, 1) => 1
count(1 -> 1 -> 1 -> 2 -> 2 -> 2 -> 2 -> 3 -> 3 -> null, 2) => 4
I've decided to bundle these two functions within the same Kata since they are both very similar.
The push()
/Push()
and buildOneTwoThree()
/BuildOneTwoThree()
functions do not need to be redefined.
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 3, 2015 |
Published | Aug 3, 2015 |
Warriors Trained | 28331 |
Total Skips | 7171 |
Total Code Submissions | 27821 |
Total Times Completed | 10391 |
JavaScript Completions | 3809 |
Python Completions | 3619 |
Ruby Completions | 579 |
Swift Completions | 670 |
C# Completions | 470 |
C++ Completions | 1223 |
NASM Completions | 32 |
COBOL Completions | 5 |
C Completions | 353 |
λ Calculus Completions | 15 |
Total Stars | 471 |
% of votes with a positive feedback rating | 92% of 1220 |
Total "Very Satisfied" Votes | 1044 |
Total "Somewhat Satisfied" Votes | 158 |
Total "Not Satisfied" Votes | 18 |
Total Rank Assessments | 29 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |