1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-09-19 22:16:57 +02:00
CodeWars/6kyu/linked_lists_length_count/solution.cpp

29 lines
352 B
C++
Raw Normal View History

/* Node Definition
struct Node {
Node * next;
int data;
}
*/
int Length(Node *head)
{
int count = 0;
while (head != NULL) {
count++;
head = head->next;
}
return count;
}
int Count(Node *head, int data)
{
int count = 0;
while (head != NULL) {
if (head->data == data) count++;
head = head->next;
}
return count;
}