Re: [algogeeks] Re: maximum subsquare such that all four borders are filled black

2014-03-31 Thread Don
00 00 010100 011100 01 00 In this case, when i and j are 1, your algorithm will set s = 3. The if statement will fail, and it will never notice that it could have formed a square with s=2. Don On Sunday, March 30, 2014 9:49:21 AM UTC-4, atul007 wrote: @don : According to

[algogeeks] Re: explanation of solution required.

2014-03-31 Thread Don
The sort is what makes this O(n*log n). The processing after the sort is O(N). So to describe the algorithm, after sorting A, it steps through the sorted array, determining what the value of K would have to be at that point such that setting the remaining values to K would cause the sum to be

Re: [algogeeks] Re: maximum subsquare such that all four borders are filled black

2014-03-31 Thread atul anand
@Don: what is the point of considering s=2 when we have already found s=3.As question says find the maximum subsquare. Which is of size 3 and this the expected outcome. On Mon, Mar 31, 2014 at 11:28 PM, Don dondod...@gmail.com wrote: 00 00 010100 011100 01 00 In this

Re: [algogeeks] Re: maximum subsquare such that all four borders are filled black

2014-03-31 Thread Don
The only square is found when s=2. Your program will look at s=3 and not find a square, so it will never find the square. Try it and you will see what I mean.. Don On Monday, March 31, 2014 2:42:13 PM UTC-4, atul007 wrote: @Don: what is the point of considering s=2 when we have already