-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcapgemini_01.java
More file actions
40 lines (27 loc) · 844 Bytes
/
Copy pathcapgemini_01.java
File metadata and controls
40 lines (27 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
Problem Statement –
You have write a function that accepts, a string which length is “len”, the string has some “#”, in it you have to move all the hashes to the front of the string and return the whole string back and print it.
char* moveHash(char str[],int n);
example :-
Sample Test Case
Input:
Move#Hash#to#Front
Output:
###MoveHashtoFront
*/
import java.util.Scanner;
public class capgemini_01 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
sc.close();
String str="";
for(int i=0;i<s.length();i++){
if(s.charAt(i)=='#')
str=s.charAt(i)+str;
else
str+=s.charAt(i);
}
System.out.println(str);
}
}