Sahilamin219's blog

By Sahilamin219, history, 7 months ago, In English

count array : for a given array it stores, for each ith element number of element greater than it's value from the left.

For a given number N , there exits an permutation array (1,N) such that it gives you same count array. You are given an count array and you have to find original array.

Example : count array => 0 0 0 1 2 0

then original array would be => 1 2 5 4 3 6

Required Solution was Nlog(N).

Hope the question is clear, if there's any doubt plz comment.

For my person experience click here

Full text and comments »

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

By Sahilamin219, history, 4 years ago, In English

I was solving some DSU question and i m not able to understand when should we do path compression and when not . For example like in these two questions .

1.Redundant Connection

Solution 1

2.Redundant Connection II

Solution 2

For better idea of solution 2 visit

As you can see in 2nd question while finding cycle we are not doing path compression. If anyone can explain the concept behind this it would be very helpful.

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By Sahilamin219, history, 4 years ago, In English

I was doing this question asked in recent HackFest in Hackerrank . I know its too simple but anyhow i m not able to score all 20 points.

my code

Please help ..i m not able to find the solution.

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it

By Sahilamin219, history, 4 years ago, In English

I was stuck in this question Your text to link here... and the editorial doesn't seem to be much helpful to me . However in the discussion section someone explained that this is the dp formula . dp[i][j] = dp[i][j-1]*i + dp[i-1][j]*j-dp[i-1][j-1]*(i-1)*(j-1) i m not able to understand how did he get the third term in the expression and more over i think this needs some correction as i was not able to get the right ans from this.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By Sahilamin219, history, 4 years ago, In English

link for question Your text to link here... i m getting wa on testcase 11 Your text to link here... after wards i modified my solution but its not working even on testcase 1.Your text to link here... i m no where able to see where is it going wrong. If you have any other idea please describe it.. i have spend a lot of time on this question

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By Sahilamin219, history, 4 years ago, In English

In this problem Your text to link here... i m getting memory limit exceeded error after submitting . I have solved this question in two other ways and may be in this i may get tle even after debugging this . But i m just curious that my map will be not be constructed of more than 10^5 key values ..than why mle ? please help. submitted codeYour text to link here...

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it