loading...

Find sublists in list by sum

github logo ・1 min read

Help me please with task.

Given a list L = (A0, A1 , A2, ..., An). Find sublists if they exist L1 = (Ai, Ai + 1, ..., Ai + k), i + k <= N, i >= 1, for which M = Ai + Ai + 1 + ... Ai + k.

For example:

L = (1 3 -16 5 7 8 2 2), M=12
Result:

L1 = (1 3 -16) //1+3-16=12
L1 = (5 7) //5+7=12
L1 = (8 2 2) //8+2+2=12

twitter logo DISCUSS
Classic DEV Post from Jun 20 '19

What does a #codeNewbie need to start/improve?

utmfcim profile image

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️