I have generated all the strings, but i am confused about how to remove the last comma and space from the output. I tried using the backspace character but that did not work on the online ide.
Unable to format output
hello @Ishitagambhir
one way is to store all ur valid strings in some vector and then u can print it in required format.
@aman212yadav i have submitted using a vector for now, but is there no other way? This will consume a lot of space.
write a similar function (that u are using to print strings ) to compute number of possible valid strings .
let say u got x as total number of strings.
now use this x to decide whether u should print comma or not.
if u have already printed x-1 strings then dont print comma otherwise print comma
1 Like