Please read the new rule regarding the restriction on the use of AI tools. ×

yashpandey73's blog

By yashpandey73, history, 3 years ago, In English

Given a 3D NxNxN matrix, such that value of A[i][j][k] is defined as i * k * ( i + j +k ) 1 <= i,j,k <= N for ex= A[1][1][1] = 3, A[2][2][2] = 24

Given a number S. Determine the max value of N such that: Sum of all array elements doesn't exceed S. for N = 2 , summation of Mat = 84 for N = 3 , Summation of Mat = 720 ( you can check that ) 3 <= S <= 1e16 any solution with O(N^2) or better complexity ?

  • Vote: I like it
  • -28
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
Rev. 2   Vote: I like it +7 Vote: I do not like it

This is a fun problem. But first, please put the link to the problem so it's not from an ongoing contest.

I assume by the lack of a link that this was from an ongoing contest. Sad, it's a fun problem, but oh well.

»
3 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

Nothing math heavy here. Take a look at "arithmetic series" in google. You can calculate sum of this matrix in constant time. It really is fun problem. Try it.

»
3 years ago, # |
  Vote: I like it +4 Vote: I do not like it

I request everyone not to post any solutions as this problem is from an ongoing hiring challenge!