Reversing the string is quiet simple in java but to remove the duplicate character in string without using and inbuild function or utility we need to do some brain storming.
There are 2 ways we can solve the problem.
1) Using Build in functions and solve the problem (Ex. Use HashSet to Remove Duplicate and Use StringBuilder to reverse the String)
2) To Use the Core logic without using any inbuild functions , here we need to use some thinking.
Below is the problem without using any in build function or utility.
So
Input - aabbcc
Output should be - abc
Input - abbcaa
Output - abca
The Time Complexity will be - O(n)
There is a simple way as well where we will only use String Buffer / String Builder and call .reverse() function of it.
If you have any problem in understanding the program , Please leave us a commet , will have to help.
Thanks for reading
Noeik
There are 2 ways we can solve the problem.
1) Using Build in functions and solve the problem (Ex. Use HashSet to Remove Duplicate and Use StringBuilder to reverse the String)
2) To Use the Core logic without using any inbuild functions , here we need to use some thinking.
Below is the problem without using any in build function or utility.
So
Input - aabbcc
Output should be - abc
Input - abbcaa
Output - abca
The Time Complexity will be - O(n)
There is a simple way as well where we will only use String Buffer / String Builder and call .reverse() function of it.
If you have any problem in understanding the program , Please leave us a commet , will have to help.
Thanks for reading
Noeik
0 comments:
Post a Comment