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.
- Prepare
- Algorithms
- Warmup
- Simple Array Sum
- Discussions
Simple Array Sum
Simple Array Sum
Sort by
recency
|
3425 Discussions
|
Please Login in order to post a comment
Leveraging Python's built-in
sum()
function simplifies the code, making it more concise and easier to read, while improving overall clarity and efficiency.this is my solution with java
public static int simpleArraySum(List ar) { int suma = 0; for(int i = 0; i < ar.size(); i++){ suma+=ar.get(i); }
The use of Python's built-in sum() function makes the code concise and easy to understand.
Using Kotlin
fun simpleArraySum(ar: Array): Int {
return ar.sum()
}
Great exercise!