import java.util.*;
public class Main {
static int bruteForceSum(int[] nums, int l, int r) {
int sum = 0;
for (int i = l; i <= r; ++i) {
sum += nums[i];
}
return sum;
}
public static void main
(String[] args
) { int[] nums = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int l = 3, r = 7; // Example range [l, r]
System.
out.
println("Brute Force Sum: " + bruteForceSum
(nums, l, r
)); }
}
aW1wb3J0IGphdmEudXRpbC4qOwogCnB1YmxpYyBjbGFzcyBNYWluIHsKIAogICAgc3RhdGljIGludCBicnV0ZUZvcmNlU3VtKGludFtdIG51bXMsIGludCBsLCBpbnQgcikgewogICAgICAgIGludCBzdW0gPSAwOwogICAgICAgIGZvciAoaW50IGkgPSBsOyBpIDw9IHI7ICsraSkgewogICAgICAgICAgICBzdW0gKz0gbnVtc1tpXTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHN1bTsKICAgIH0KIAogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIGludFtdIG51bXMgPSB7MCwgMSwgMiwgMywgNCwgNSwgNiwgNywgOCwgOX07CiAKICAgICAgICBpbnQgbCA9IDMsIHIgPSA3OyAvLyBFeGFtcGxlIHJhbmdlIFtsLCByXQogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiQnJ1dGUgRm9yY2UgU3VtOiAiICsgYnJ1dGVGb3JjZVN1bShudW1zLCBsLCByKSk7CiAgICB9Cn0=