How efficient is this algorithm?

I tried it, doesn’t work. Does it work for you?..