codes for algorithm and welcome to disscuss