# Display 1,2,3,4,5,6,8,10,11 as 1-6,8,10-11?

> I have this sequence **1,2,3,4,5,6,8,10,11** > > Expected output is **1-6,8,10-11** This problem is about formatting the sequence in easy readable form I tried with c# and used many if & else. Interviewer said, there is some simple algorithm to do this. I have no idea how to achive this very simple. > Also for 1,2,3 i shown 1-3. They said its wrong!. Is there any design pattern(interpreter) involved in this logic?

By: