Update appNew update is available. Click here to update.
About
As a recent college graduate, I know that what Im lacking is career experience. However, the qualifications that I bring cannot be measured by traditional experience. After holding offices in four dif...
Dr. APJ Abdul Kalam Women's Institute of Technology 2023
My Stats
EXP gained
yellow-spark
408
Level
3 (Seasoned)
Community stats
Discussions
0
Upvotes
0
Know more
22
Total problems solved
21
Easy
1
Moderate
0
Hard
0
Ninja
Dec Dec Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov

Current streak:

0 days

Longest streak:

1 day

Less

More

Discussions
JAVA BEST APPROACH
Interview problems

This code belongs to java and also this code is beginner friendly,

 

static String reverseStringWordWise(String input) {

        // Write your code here

        String ans = "";

        int i = input.length()-1;

        while(i>=0){

            while(i>=0&&input.charAt(i)==' ')i--;

            int j = i;

            while(i>=0&&input.charAt(i)!=' ')i--;

            if(ans.isEmpty()){

                ans = ans.concat(input.substring(i+1,j+1));

            }else{

                 ans = ans.concat(" "+input.substring(i+1,j+1));

            }

 

        }

        return ans;

    }

profile
Prashant Saxena
Published On 28-Nov-2023
7 views
0 replies
0 upvotes