Getting WA in most test cases
@Ishitagambhir
There is 2 mistakes in your code
- The formula used in line 8 should be (((x) * (x+1)* ranks[i])/2) . You haven’t divide it by 2
- line 11 should be parantheCooked += (x-1); x has 1 more than the actual value.
@shrm.abhishek.kmr i had put in the x–; statement after the while loop but it was giving incorrect answer for the test case so I removed it. Thank you so much, it is working now.
1 Like