[algogeeks] Re: Google Interview Question: find shortest summary containing all key words

2007-10-12 Thread Andrey
You'd better wite a program. On 11 окт, 10:42, Vaibhav Jain [EMAIL PROTECTED] wrote: Algo: 1. initialize final_result array with whole sequence and count number of keywords in no_of_keys and initialize counter array for keywords with value zero. 2. if sequence_ptr is not null then start

[algogeeks] Re: NxN matrix of positive and negetive integers?

2007-10-12 Thread Lego Haryanto
The explanation above is correct ... O(n^3) is enough. If you're able to solve the one dimensional array in O(n), then you can solve the 2D case in O(n^3). For each row-range [a..b], we'll compute the maximum contiguous subarray with the O(n) above. To achieve O(n^3), this means that for each

[algogeeks] Re: Google Interview Question: find shortest summary containing all key words

2007-10-12 Thread Andrey
You'd better write a program. On Oct 11, 10:42 am, Vaibhav Jain [EMAIL PROTECTED] wrote: Algo: 1. initialize final_result array with whole sequence and count number of keywords in no_of_keys and initialize counter array for keywords with value zero. 2. if sequence_ptr is not null then

[algogeeks] Re: NxN matrix of positive and negetive integers?

2007-10-12 Thread Andrey
I doubt It will be O(n^3).. Dynamic programming algorithm, by size of submatrix, will give at least O(N ^ 4), won't it? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

[algogeeks] Re: NxN matrix of positive and negetive integers?

2007-10-12 Thread Andrey
Does anyone knew more effective solution then DP? On Oct 12, 3:46 pm, Andrey [EMAIL PROTECTED] wrote: I doubt It will be O(n^3).. Dynamic programming algorithm, by size of submatrix, will give at least O(N ^ 4), won't it? --~--~-~--~~~---~--~~ You received

[algogeeks] Re: NxN matrix of positive and negetive integers?

2007-10-12 Thread Andrey
I've found task 108 [ http://acm.uva.es/p/v1/108.html ] but there is nothing except task statement. I have written a program that solves this problem (see listing below) but It has complexity = O(N^4). Please look at my program it's quite simple to understand and prints debug output (see at the