## navid

BAN USERJust save the matrix c(i,j)= sum(a[i]..a[j]) where "a" is the original array. c(i,j) can be computed in O(n^2) time.

The just for each tuple (i,j) check whether c(i,j) = c(j+1,j+1+j-i) find the one with max(j-i)

Total time and space complexity O(n^2)

is anyone has a n.log(n) solution?

The sums are over the digits in each number in the sequence and not the sequence itself. Example

for sequence of 201,202,..,230

the numbers you are looking for are 210 (2-1+0=1), (220 2-2+0=0) 221 (2-2+1=1) and 230 (2-3+0=-1).

My previous solution would work if we have binary representation of the numbers but it can also work if we have any other representation. basically you can recurs on the number of digits.

if (a0...ak) for all numbers a0=c are in the range find the number of numbers in with k-1 digit where the difference between sum of even and odd digits is equivalent to [c-1,c+1].

No, it doesn't work. AVL tree are balanced based on just the height of the left subtree and right subtree. There could be a big difference between the actual number of nodes in the two subtree.

For example, assume left subtree is a full binary tree of height k and right subtree is a full binary tree of size k minus one leaf deleted for all the nodes in the second to last level. The balance factor is 1 but the difference between the nodes in the subtrees are huge.

AVL tree seem to do jack squat for reducing the order of finding median. You can use it to get a sorted order and find the median which is still going to be O(n) which is order equivalent to finding the median in an array in the first place.

Anyone knows anyway which actually reduces the order, please email me. I am really interested to know.

Rep**AsaDills**, HR Executive Trainee at Cerner CorporationI 'm Asa Dills, My role of the Public Housing Manager (PHM) is complex. the financial viability of the property ...

RepSpent several months writing about boyfriend ki shadi todne ke upay .Spent 2001-2007 donating carp in Las Vegas, NV. My ...

RepSpent 2001-2006 licensing the elderly in Jacksonville, FL. Spent 2001-2004 consulting about Break Up Spell. Spent two years deploying crickets ...

Rep**terricjohnson8547**, Animator at 247quickbookshelpHello, I am a dancer. I have completed my studies from New York. And today I am a dance teacher ...

Rep**queznister**, Android test engineer at Aspire SystemsI supervise the day-to-day operations of the store. assign duties. Determine staffing requirements, oversee their hiring, and, when needed, dismiss ...

Rep**liliylinda619**, Area Sales Manager at Alliance Global ServiesMy name is Sarah Torres and I am a Fitness director in the Independent Planners. I am a very kind ...

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Doesn't work, 6! is divisible by 16 but this algorithm would return false;

Instead use gcd. Change code to this where gcd(int,int) returns the greatest common denominator of two integers.

- navid June 01, 2014