We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
You can't. What you can do is, do the comparisons and output at the same time, so when you find a cavity, output an X instead of the digit. While you could have read the input as characters and compared and assigned the X, using integers is generally easier to understand, so I would prefer reading the input as integer. But if you want to stick to keeping the processing and output separate, use a 2D character array.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Cavity Map
You are viewing a single comment's thread. Return to all comments →
You can't. What you can do is, do the comparisons and output at the same time, so when you find a cavity, output an X instead of the digit. While you could have read the input as characters and compared and assigned the X, using integers is generally easier to understand, so I would prefer reading the input as integer. But if you want to stick to keeping the processing and output separate, use a 2D character array.