Update gem_stones

better time and space comlexity

u donot requireet to store the inputs
process it then only