I am having doubt related to a question on Hacker blocks

the question named prime visit, i am getting a Tle on one test case while other test cases are accepted

hello @gods_eye
pls refer this -> https://www.youtube.com/watch?v=8sniiDbfPK4