0
Java interview question
Given a string "aaabbbcc", compress it, = "a3b3c2" . Given that output string's length is always smaller than input string, you have do it inplace. No extra space Please answer anyone
4 Réponses
0
Is there any other constrains?
If there is atleast one, one char of 3times then only string length is become smaller than original.
Use a for to traverse string, start at index 1.
If charAt(i) ==charAt(i-1)
count increment, continue,
Else append char and count, proceed to next one... This way you can do it...
There may be better solution...
Edit: As a code practice, can you try to code and share it?
+ 5
Post your code then we will help you
0
i dont know code
that was the question to code
0
There are somany java interview questions found on google. If you're looking for those questions to crack the interviews, then go through these blogs:
* https://www.javatpoint.com/corejava-interview-questions
* https://www.interviewbit.com/java-interview-questions/
* https://www.techgeekbuzz.com/core-java-interview-questions/
* https://www.techgeekbuzz.com/top-tcs-interview-questions/
You can find somany java interview questions that can help you land your dream jobs.