You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
lang-java
-but what if the input can have a hyphen before? for example10N-10Nin this case the 3rd replace will replace also this hyphen, but the second solution don't need that 3rd character, It loop over all character and check if it is equal to N then return 1 else if N return it with 1 and in the end collect all the result this is what is mean by "more secure solution" hope you get it