P21748 [GeeksforGeeks] Java delete alternate characters4036
普及-
题目描述

Given a string S as input. Delete the characters at odd indices of the string.
Example 1:
Input: S = "Geeks"
Output: "Ges"
Explanation: Deleted "e" at index 1
and "k" at index 3.
Example 2:
Input: S = "GeeksforGeeks"
Output: "GesoGes"
Explanation: Deleted e, k, f, r, e
k at index 1, 3, 5, 7, 9, 11.
Your Task:
You dont need to read input or print anything. Complete the function delAlternate() which takes S as input parameter and returns the final string after deletion of characters at odd indices.
Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(|S|)
Constraints:
1<= |S| <=1000

输入格式

见题面

输出格式

见题面

样例输入
S = "Geeks"
样例输出
"Ges"