You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Moves all '#' characters to the end of the given string while preserving
5
+
* the order of the other characters.
6
+
*
7
+
* Example:
8
+
* Input : "h#e#l#llo"
9
+
* Output : "hello###"
10
+
*
11
+
* The algorithm works by iterating through the string and collecting
12
+
* all non-# characters first, then filling the remaining positions
13
+
* with '#'.
14
+
*
15
+
* Time Complexity: O(n)
16
+
* Space Complexity: O(n)
17
+
*
18
+
* @see <a href="https://www.geeksforgeeks.org/move-special-char-end-string-maintain-order-alphabets/">Move all special characters to end - GeeksForGeeks</a>
19
+
*/
20
+
publicfinalclassMoveHashToEnd {
21
+
22
+
/**
23
+
* Private constructor to prevent instantiation of utility class.
24
+
*/
25
+
privateMoveHashToEnd() {
26
+
}
27
+
28
+
/**
29
+
* Moves all '#' characters in the input string to the end.
30
+
*
31
+
* @param str the input string containing characters and '#'
32
+
* @return a new string with all '#' characters moved to the end
0 commit comments