We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7757232 commit 0f5644fCopy full SHA for 0f5644f
reverseonlycharacter.java
@@ -0,0 +1,26 @@
1
+public class reverseonlycharacter{
2
+ public static void main(String[] args){
3
+ String str="12ab$c";
4
+ //output string="12cb$a"
5
+ char[] c=str.toCharArray();
6
+ int left=0;
7
+ int right=c.length-1;
8
+ while(left<right){
9
+ if(!Character.isAlphabetic(c[left])){
10
+ left++;
11
+ }else if(!Character.isAlphabetic(c[right])){
12
+ right--;
13
+ }else{
14
+ char temp=c[left];
15
+ c[left]=c[right];
16
+ c[right]=temp;
17
18
19
+
20
+ }
21
22
+ String res=new String(c);
23
+ System.out.println(res);
24
25
26
+}
0 commit comments