Weird error please help in invalid types ‘long long int[long long int]

Que link : “Special paths | Binary Search & Algorithms Practice Problems | HackerEarth

My solution1 : “DBCFKQ - Online C++ Compiler & Debugging Tool - Ideone.com” (AC)

My solution2 : “Jw5Osx - Online C++ Compiler & Debugging Tool - Ideone.com” (compile error)

in solution 2 I got compile error invalid types ‘long long int[long long int]

don’t know why ? please help @ssjgz @carre @cubercoder

lli val = abs(val[x]-val[y]);
       ^ At this point, you've introduced a name "val", of type "long long int".
           So "val[x]" is trying to index into a variable of type long long int!

Use a different name e.g.

            lli value = abs(val[x]-val[y]);
            if(value<=mid)
            {
                dsu.Union(x,y);
            }
3 Likes

ah shit mannn … :frowning_face: i m trying to figure out from last 20 minutes :crying_cat_face:

1 Like

Thanks :slight_smile: @ssjgz