What is the most efficient way to add an integer to part of a list?
Example :
input : [1,5,3,7,4,3]
range of list to modify is 2,4
add 3 to range
output : [1,5,6,10,7,3]
Explanation :
First get the sublist using indexes 2 and 4.
Then add 3 to the values in that index. then return a list containing the modified range.
I tried using a loop but its not fast enough. Need a faster method.