coding 4

method 2