Class doubt @lexicographical larger

https://ide.codingblocks.com/s/50476

can u plz tell me what is “flag” doing and explain whats happening thereafter?