Help in CSUM (Java)

I tried to solve this problem: CSUM Problem - CodeChef
I’m getting some error which I’m unable to identify.
My solution: CodeChef: Practical coding for everyone

I was trying to fix TLE issues so the code might seem a little complicated but it is not.

Here’s a completely randomly-generated testcase where your solution fails:

1
20 63
54 2 23 23 57 4 5 5 48 44 35 8 63 18 14 40 13 9 64 27
1 Like

I tried a new method but it still doesn’t work. Can you spot any possible flaws?

        Boolean con=false;
        int j=0;
        while (!con && a[r]>=k/2)
        {
          if (a[j]==req) 
          {
              con=true;
          }
          else if (j<r-1)
          {
              j++;
              continue;
          }
          else if (r>1)
          {
              j=0;
              r--;
              continue;
          }
            break;

        }
        
        if (con) System.out.println("Yes");
        else System.out.println("No");

Can you post the whole code, please?

1 Like

nvm i just found the problem and my answer is correct. Here is the code if you want to see: CodeChef: Practical coding for everyone

1 Like