We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home
  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Functional Programming
  3. Introduction
  4. List Length

List Length

Problem
Submissions
Leaderboard
Discussions
HackerRank Logo
|
  1. Prepare
  2. Functional Programming
  3. Introduction
  4. List Length
Exit Full Screen View
  • Problem
  • Submissions
  • Leaderboard
  • Discussions

Count the number of elements in an array without using count, size or length operators (or their equivalents). The input and output portions will be handled automatically by the grader. You only need to write a function with the recommended method signature.

Input Format

A list of integers, each on a separate line.

Output Format

Output a single integer , the length of the list that was provided as input.

Sample Input

2
5
1
4
3
7
8
6
0
9

Sample Output

10

Constraints


Each element, , in the list:

Recommended Method Signature

Number Of Parameters: 1
Parameters: [list]
Returns: Number

For Hackers Using Clojure

This will be the outline of your function body (fill in the blank portion marked by underscores):

 (fn[lst]___________________________)

For Hackers Using Scala

This will be the outline of your function body (fill in the blank portion marked by underscores):

 def f(arr:List[Int]):Int = __________________

For Hackers Using Haskell

This will be the outline of your function body (fill in the blank portion marked by underscores):

 len lst = __________________  

For Hackers Using other Languages

You have to read input from standard input and write output to standard output. Please follow the input/output format mentioned above.

NOTE: You only need to submit the code above after filling in the blanks appropriately. The input and output section will be handled by us. The focus is on writing the correct function.

  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Helpdesk
  • Careers
  • Terms Of Service
  • Privacy Policy

Cookie support is required to access HackerRank

Seems like cookies are disabled on this browser, please enable them to open this website