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
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Functional Programming
  3. Introduction
  4. Sum of Odd Elements

Sum of Odd Elements

Problem
Submissions
Leaderboard
Discussions

You are given a list. Return the sum of odd elements from the given list. The input and output portions will be handled automatically. You need to write a function with the recommended method signature.

Constraints

The list will have elements.
Each element will be an integer where .

Sample Input

3
2
4
6
5
7
8
0
1

Sample Output

16

Explanation

Sum of odd elements is

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):

 f arr = ______________________

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.

Author

idlecool

Difficulty

Easy

Max Score

10

Submitted By

23591

Need Help?


View discussions
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature