Python Solution | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python Solution

Here is a link for the problem that I tried to solve in Hacker earth but couldn't solve it. https://www.hackerearth.com/practice/algorithms/dynamic-programming/2-dimensional/practice-problems/algorithm/array-and-sums-6e5e7323/ Please provide me a solution for this using Python language and a brief explanation for the same

12th Jul 2020, 7:38 AM
Neeraj Jain
Neeraj Jain - avatar
3 Answers
+ 6
Hello and welcome to sololearn We can't do work homeworks here so you have to show your attempt so that we may help you :) What you have to do just paste your code here https://www.sololearn.com/post/75089/?ref=app https://www.sololearn.com/discuss/333866/?ref=app
12th Jul 2020, 7:43 AM
Nilesh
Nilesh - avatar
0
Here's what I tried: def sublists(arr): sub = [[]] for i in range(len(arr) + 1): for j in range(i + 1, len(arr) + 1): s = arr[i:j] sub.append(s) return sub a = [1, 2, 3, 4, 5, 6, 7, 8] n = 5 a.remove(n) new_list = a s = sublists(new_list) new_s = [] for i in range(len(s)): if sum(s[i]) == 5: new_s.append(s[i]) else: continue print(new_s)
12th Jul 2020, 8:23 AM
Neeraj Jain
Neeraj Jain - avatar
0
Nilesh please help me find a solution for this problem
12th Jul 2020, 11:23 AM
Neeraj Jain
Neeraj Jain - avatar