![]() |
VOOZH | about |
Given a string str and an integer position pos, the task is to delete the character at the specified position pos from the string str.
Examples:
Input: str = "GeeksforGeeks", pos = 5
Output: GeeksorGeeksInput: str = "HelloWorld", pos = 0
Output: elloWorld
Traverse the string and push all the characters to another string or character array except the character which needs to be deleted. We will shift the characters to the left starting from the specified position to delete the character.
Below is the implementation of the algorithm:
Modified string: GeeksorGeeks
Time Complexity: O(n) where n is the length of the string.
Auxiliary Space: O(n) where n is the length of the string.
We will use the built-in functions or methods provided by the respective programming languages to delete the character at the specified position in the string.
Below is the implementation:
Modified string: GeeksorGeeks
Time Complexity: O(n) where n is the length of the string.
Auxiliary Space: O(n) where n is the length of the string.