Sum of Elements between k1'th and k2'th smallest elements
Easy

Problem Statement

Given an array of integers and two integers k1 and k2, find the sum of all elements between the k1'th and k2'th smallest elements of the array.

Examples

1Example 1
Input:
{ "nums": [ 20, 8, 22, 4, 12, 10, 14 ], "k1": 3, "k2": 6 }
Output:
26
2Example 2
Input:
{ "nums": [ 10, 2, 50, 12, 48, 13 ], "k1": 2, "k2": 6 }
Output:
73
3Example 3
Input:
{ "nums": [ 1, 2, 3, 4, 5, 6 ], "k1": 1, "k2": 6 }
Output:
14
Loading...

Sign in to Run Code and Submit