Comments

I did, just didn't submit

Easiest D ever seen

What could be the difficulty ratings for all the problems ?

Who is StackExchange ?

+2

One other way to do E is my considering 9 based numbers instead of 10 based(decimal) numbers. Convert k to a 9 based number and change all 4's to 5, 5's to 6, 6's to 7, 7's to 8 and 8's to 9

Don't tell me you submitted the wrong solution 4 times just to comment this

yep, you got it

Did you actually get it? My solution was too complex

(Everything is 1-indexed) Case 1: k is 0 fill whole array with -1.

Case 2: k is of the form (n*(n+1))/2. Let x = (n*(n+1))/2. Fill the first n elements of the required array with 1 and the remaining ones with (-1000)

Case 3: k is not of the form (n*(n+1))/2. Find highest index i such that (i*(i+1))/2<k. Let count=k-(i*(i+1))/2. Fill first count elements of the array with 30 and remaining elements upto i with 1. Fill ith index with -31 and rest of the array with -1000

C is a constructive algo based problem. There are usually multiple ways to solve these kind of problems

0

Yep I got it, but thanks anyways

+1

For G2 and G1, after sorting the array I knew that that one of the conditions was that every element should be at max the sum of all the elements that occured before it. Little did I know that it was the only condition required. Could someone explain me why we can always make every number from [1 — sum of all elements occured] from the given elements ?

0

It will take some time for your rating to update

0

Can you explain why ?

Because for each iteration of the 'forloop', if you notice carefully the 'while loop' is running at most once. So at the end it is a O(n) solution