nekomata_saren@tg
says to
YSITD
O(n)解法