https://ide.codingblocks.com/s/226253 Please check the code
@kt62495 Just increase the size of your ans array.