CanYouReadThis Question

here i think we can make use of string tokenisation function but am not getting how to pass the char as in uppercase, i.e, we have to break string around uppercase alphabets and that char’s may range from A to Z, so how to solve the question by this way?

The intuition is right, make a check function in which your delimitator char should lie in ASCII value ranging between 65 to 90 as all the letters are capital in this range.

Yeah thought approach is somewhat is this only but unable to implement it

But solving this question using strtok() is not recommended , let me tell you why , using strtok() what you do is u split the string into several parts based on the delimiter eg:-

if str=“Abhijeet_kumar_jha”
and delimiter passed is “_”
then we will have three strings [“Abhijeet”,“kumar”,“jha”] also note that delimiter is not attached with any of the string.
but in this question we have to split the string based on the occurrence of capital alphabets, which introduces two main problem in this approach :-

  1. the delimiter is variable, as there are 26 capital alphabets so would’nt be able to specify a unique delimiter , or we would have to split the string several time for each capital alphabet
  2. we have to include the capital alphabet in the word , as in strtok we don’t include the delimiter

so , i would suggest you to think of some different algorithm ,as implementing this would be tough and pointless as we can do this question with much ease without using any fancy algo

I changed the approach but it is not producing any output. Here is the link :- https://ide.codingblocks.com/s/407195

Don’t use strtok it will make it complex only. Read my last message, do it by iterating every character ofthe string and when you will get any capital letter add a new line and then print it.

I have done that method only, I think that was displaying the previous try. Here is with the new approach I have applied :- https://ide.codingblocks.com/s/407210

Check now =>


Will pass test cases. Always do dry run after you come up with an approach. By doing this, you will be able to get the intuition for side cases as well.

Thank you. Got the approach now.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.