Fexle Services interview question

to generate a code for star patterns using java