Watch the video for explanation, and to practice and read editorials around these problems, use the given below links.