Sort by

recency

|

11 Discussions

|

  • + 1 comment

    Can be solved in O(n), but O(nlogn) works fine as in LIS.

  • + 0 comments

    linear time complexity

  • + 0 comments

    Time out in last three case my C++ code is int findMaxIndex(vector a,int n) { int c=INT_MIN,index; for(int i=0;ic) { c=a[i]; index=i; } } return index; } int main(){ int g,count; cin >> g; for(int a0 = 0; a0 < g; a0++){ int n; count=0; cin >> n; vector a(n); for(int i=0;i>a[i]; } while(n!=0) { n=findMaxIndex(a,n); count=count+1; } if(count%2==0) cout<<"ANDY\n"; else cout<<"BOB\n"; } return 0; } any body can explian me , why ?

  • + 0 comments

    I just the Editorial. It has the same logic I used but still code is being timeout. what must be the reason?

  • + 1 comment

    timeout in last four test cases. in my python code. i don't know what is wrong. can any one help me?

    #!/bin/python
    import sys
    g = int(raw_input().strip())
    for a0 in xrange(g):
        n = int(raw_input().strip())
        A = [int(e) for e in raw_input().split()]
        res = 0
        while len(A)>0:
            A = A[:A.index(max(A))]
            res += 1
        if res%2 == 0:
            print "ANDY"
        else:
            print "BOB"