Finoit Interview Question

in coding round they ask some complicated question like,. Reverse a string that reverse their character but do not change their position e.g- HELLO WORLD - OLLEH DLROW

Interview Answers

Anonymous

Sep 13, 2019

int spc; int count=0; void revString() { String s1="HELLO WORLD IS"; char[] c=s1.toCharArray(); for(int i=0;i=0;j--) { System.out.print(c[j]+""); } System.out.print(" "); spc=i;//5 count++;//1 } else if(c[i]==' '&&count!=0) { for(int j=i-1;j>spc;j--)//i=11 & spc=5 { System.out.print(c[j]+""); } System.out.print(" "); spc=i; count++; } else if(i==s1.length()-1) { for(int j=s1.length()-1;j>spc;j--) { System.out.print(c[j]+""); } } }

Anonymous

Oct 9, 2019

It's Python: ' '.join([word[::-1] for word in sentance.split()])

1

Anonymous

Oct 18, 2019

import java.util.Scanner; public class reverseatposition { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str=sc.nextLine(); String arr[]=str.split(" "); for(int i=0;i