Made several stupid mistakes in changing bits but got it eventually. O(sqrt(N)) per query is fast enough. Now I got 24/29 solved.
Solved Problems
String Reduction: greedy with reducing max cnt char
Permutation game: easy bit
Task Scheduling: segment tree
Circle Summation: matrix mult
Quadrant Queries: segment tree
K Difference: easy
String Transmission
EQUATIONS: factor
Lego Blocks: dp with a wall to cut
Grid Walking: dp with precalculation
String Similarity
Substring Diff
Vertical Sticks: indepdently calculate each stick
FIND STRINGS
ARITHMETIC PROGRESSIONS: ans is q!*d^q1*d^q2..., when q is more than MOD, then ans is 0
Meeting Point: axis transformation to get L1 norm
Changing Bits: blocks of sqrt(N)
Save Humanity: overlap two prefix match (forward and reverse) to obtain a match with 1 error
Stone Piles: Grundy number and sum of games, very tricky
Billboards: minimize throw away, sliding window
Kingdom Connectivity: topological sort with cycle detection
Square Subsequences: try all split and find common substr
Fairy Chess: moving diamond and edges
Connect the country: simulation
Subscribe to:
Post Comments (Atom)
hi..please see my comment on your posts.
ReplyDeleteHi...m looking into the problem permutation game....but get stuck....looking for some hint that how to proceed
ReplyDeletethis is a standard combinatorial game problem. Just use DP with memorization to check each state being win or lose,
Deletea state is win if it can reach a lose state
a state is lose if all its next state is win
Hello,
ReplyDeleteCan you give me clue for Vertical Sticks problem.
calculate each stick individually
ReplyDeleteHi,Can you explain a bit more on using a sliding window for BillBoards,i am stuck with DP of complexity O(nk)...
ReplyDeleteUse a MaxHeap to deal with the K elements you need to deal with in the n loop
Deletehow can segment tree apply to task scheduling problem?
ReplyDeletebasically it is shortest job first but you need to do a lot of updates, use lazy updates to be within time limit. The use of segment tree is a bit hard to explain, I need to look at my code since it has been a while
Deletecan you tell what the segments represent, i mean is it the Task numbers, Deadlines, Time Remaining, Overshoot ?
DeleteLike the segment [3-4] represents what?
Thanx
You are so smart....
ReplyDeleteHello,
ReplyDeleteCan you help me with quadrant queries?
I have tried with segment tree storing the number of X-queries and Y-queries, but when i try to compute C-queries it's still linear because I have to consider all points.
I don't see how to use the in a different way.
Thanks for your help
You only need the number of points in each quadrant, not the actual points. And you need the idea of lazy propagation, e.g. if you apply X query on range [i,j], the children under [i,j] are not updated until you have to split into the children range.
ReplyDeletehey Li Yan,
ReplyDeletefor the GRID WALKING problem in interviewstreet, could you paste you output for this input...
1
4 4
5 5 5 5
9 9 9 9
hey i got this...
Deleteit's answer is 4096...
This comment has been removed by the author.
ReplyDeletePROBLEM PLEASE HELP...
ReplyDeletei was able to solve this problem by two ways..
i am facing problem when the input is like...
1
10 300
2 2 2 2 2 2 2 2 2 2
10 10 10 10 10 10 10 10 10 10
what should i do please help.....
Hello Anubhav,
DeleteThanks for your reply. I solved it.
And for the testcase you asked, the answer is
292695773
Thanks again
Cheers,
hi
Deletecould you please help me with the memory issue...(OUTOFMEMORY)
my code goes out of memory when solving such a large problem in java.(see problem above)
hi Li Yan,
ReplyDeleteI am facing the same problem in Quadrant Queries like you before, I am able to solve it till 10/11 test case,but in 11th test case it's crossing time limit.
Please give a clue what should i do.
Thank you,
Anubhav
finally able to solve that problem by myself
Deletenow i am getting 11/11 test cases passed.
i was doing a silly mistake in query part....
Anubhav
Hi Li Yan,
ReplyDeleteI tried solving Kingdom connectivity using DFS which also detects the loop in graph but only able to get through 2 test cases. Can you please guide.
Some help on Changing Bits, Except the fact that we need to compute only the bit which is being referred in the get_c command
ReplyDelete