Some algorithm problem