Hacker Earth Amazon All India Hiring Contest

Hey @vidyut_1 @vipin1407 @samarthtandon
I was able to solve first question completely and I got only 30 points (TLE for rest of cases ) in 2nd question even though I had solved using same approach as you all did using treeset.
Can you just tell where did I go wrong ?

static int[] GreaterEqual(int[] A, int[] X, int[] u, int[] L, int[] v){
    // Write your code here
    
    int[] ans = new int[X.length];
    ArrayList<ArrayList<Integer>> g= new ArrayList<>();
    
    ArrayList<TreeSet<Integer>> lvl = new ArrayList<>();
    for(int i=0;i<u.length+2;++i){
        g.add(new ArrayList<Integer>());
        lvl.add(new TreeSet<Integer>());
    }
    for(int i=0;i<u.length;++i){
        g.get(u[i]).add(v[i]);
        g.get(v[i]).add(u[i]);
    }
    
    LinkedList<Integer> q =new LinkedList<>();
    int md=0;
    boolean vis[]= new boolean[u.length+2];
    int[] wl= new int[u.length+2];
    q.add(1);
    while(!q.isEmpty()){
        int n=q.poll();
        if(vis[n]) continue;
        vis[n]=true;
        lvl.get(wl[n]).add(A[n-1]);
        
        ArrayList<Integer> adj= g.get(n);
        
        
        for(int x:adj){
            if(!vis[x]){
            wl[x]=wl[n]+1;
            md=Math.max(md,wl[x]);
            q.add(x);
            }
            
        }
        
    }
    for(int i=0;i<ans.length;++i){
        int ll=L[i]%(md+1) ;
        Integer aa=lvl.get(ll).ceiling(X[i]);
        if(aa==null){
            ans[i]=-1;
        }
        else{
            ans[i]=aa;
        }
        
        
    }
    
    return ans;

}

Hi @cis_pie,
Your code is fine. This issue is in the “System.out.println” statement. I also got TLE because of that.
I had to change to “BufferedWriter” to resolve the TLE.
Thanks

@ganesh92
Problem statments are not visible now.

@vidyut_1
So much disappointing… :frowning:
I was too much frustrated at that point because i submitted this solution in last minute.
is there anything that I can do now ? like mail them and tell them that its just fast input output ?
Can I submit same code again and then share link with them ?
Can we submit again ? I think problems are not in practice section.

I think you should mention them about this fast input output issue. The “System.out.println” code was given by them. We were supposed to complete the methods.

Problems are in the practice section :slight_smile:

yes submitted and got AC by just changing output method.
https://www.hackerearth.com/submission/26466892/

1 Like

Thanks, @vidyut_1
Changed output from Sytem.out.println to printwriter.println and it magically passed :slight_smile: but I could not do that during contest.

Orginal : https://www.hackerearth.com/submission/26155174/
Changed only output method : https://www.hackerearth.com/submission/26466892/

hurray:partying_face::partying_face::partying_face::partying_face::partying_face:

you are welcome :slight_smile:

1 Like

Hi @vipin1407 when is your interview scheduled?

Nope…I don’t know why…I score full 200 :disappointed:

1 Like

here is the link for DRY RUN

1 Like

anyone from 2020 batch get the mail ??

1 Like

I think people from 2-3rd year did not get any mail. Which year are you in???

3rd year 2020 batch …

I completed both the questions , still haven’t received any email. Anyone has any idea what could be the possible reason?..or should I wait till 10th june.

IAM from 4th year.i solved both the questions but didn’t get the mail.

Even I solved both the questions, that too within 30 mins…still didn’t received the mail! Disappointed!!

Means there are chances to get mail until 10 june