Problem Description Link
Algorithm:
In this problem if you compare with "." and increase the adjacent value it is more time consume and get garbage value when row=0 or row=n
in this case no have 8 adjacent value.
so you can compare with "*" and generate another 2D value array that contain only value.
if get "*" in input array then increase the all adjacent value and store that value in value array.
After generating the all value check from input array if character is "*" then print the "*" otherwise print from value array for this position.
Algorithm:
In this problem if you compare with "." and increase the adjacent value it is more time consume and get garbage value when row=0 or row=n
in this case no have 8 adjacent value.
so you can compare with "*" and generate another 2D value array that contain only value.
if get "*" in input array then increase the all adjacent value and store that value in value array.
After generating the all value check from input array if character is "*" then print the "*" otherwise print from value array for this position.