https://ide.codingblocks.com/s/54768
the code is failing one test case. wht is the error ?
you are using max as 500. You should use it around 100000. Your code will work properly. Hit like if u get it