Question bank › Linked List
Dsa Linked List Warm-up

Count Elements in Linked List

You need to count the total number of nodes in a linked list. The linked list nodes are represented as space-separated integers followed by -1. Input format: - A single line containing integers representing the linked list followed by -1. Output format: - A single integer representing the total count of nodes in the linked list (excluding -1). Example: Input: 1 2 3 4 -1 Output: 4

Key concepts

linked_listcountingtraversal

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.