DomainExpansion's blog

By DomainExpansion, history, 8 months 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.

Read more »

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

By DomainExpansion, history, 10 months 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.

Read more »

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

By DomainExpansion, history, 13 months 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.

Read more »

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

By DomainExpansion, history, 13 months 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

Read more »

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

By DomainExpansion, history, 13 months 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...

Read more »

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