Thursday, January 5, 2012

interview street challenge update

Solved string reduction. Now have 7.

Claire gave a very simple solution which also has a simple proof of correctness. Keep working on char with max cnt and another neighboring char until no more operation is possible. You must be left with 1 or 2 equal char. My solution is much more complicated and I do not have a good proof so far.

Your rank: 71
Your score: 460.625

Jan 6 update: hacked the bipartite matching code a bit and had 2 more testcases passed for problem solving problem.
Your rank: 66
Your score: 479.625

Jan 7 update: one more problem AC, string transmission. enumerate all periods and some simple DP with memorization.

Your rank: 63
Your score: 513.5

It gets harder to move up in rank now.

Jan 08 update
Had 2/10 for circle summation. Why TLE.
After 3 TLE, lost all 6pt earned for this problem. Back to 63.

solved circle summation, need O(N^2 logM) where N=50, M=10^9
Your rank: 61
Your score: 526
Rank Hacker Country Score Submissions Solved
61 lantimilan NA 526.00 36 9

Solved Equations, the answer is derived by x*y/(x+y)=N! and then ans is the number of factors of N!^2.
EQUATIONS C++
Submission Accepted
15/15 testcases passed
45 Point(s)
View Submission Processed 2012-01-09 01:22 UTC

Lego blocks: A simple DP problem, I don't know why I didn't solve it earlier.

Lego Blocks C++
Submission Accepted
10/10 testcases passed
50 Point(s)
View Submission Processed 2012-01-09 05:42 UTC

Now has 11. The remaining problems would be tough.

11 comments:

  1. Would you help give some hints on Lego blocks?
    I don't know how to represent the state of this DP problem.
    Many thanks.

    ReplyDelete
  2. draw some picture and you can probably see a pattern. topcoder has a similar or same problem before, although I didn't recall where it is. My idea is to split at some vertical line so the two parts left and right can be solved separately.

    ReplyDelete
  3. hi
    how do u calculate n!^2 when n is very large say 10000

    ReplyDelete
  4. I do not know any way to calculate n! faster than O(n).

    ReplyDelete
  5. Hey ! One of the test case for billboards problem us giving TLE. I am using O(NK) time complexity. Any suggestion ?

    ReplyDelete
  6. About Lego Blocks: My DP solution has 9/10 accepted. I am at a loss as to why 1 test case failed. these type of failures turn out to be very are hard to fix. Could you please share what precautions had you taken for boundary cases ? Any tricky boundary cases ?

    ReplyDelete
  7. Never mind, I figured that out. I have an AC now.

    ReplyDelete
  8. I take the same idea to deal with the Equations 1/x+1/y=1/N! problem,but I found my program can't pass the test01.I wonder where is wrong ....so frustrated.

    ReplyDelete
  9. I tried to solve the "Problem solving" using greedy: delete the longest path every time. However the result is wrong, could you give me some suggestion? Thanks

    ReplyDelete
  10. 2
    4 6
    4 5
    plzz tell output of above testcase

    ReplyDelete
  11. some help with the DP of string transmission?

    ReplyDelete