Can someone please help me with my homework? Itâs only my second week in the class and we have not reviewed this at all!
You can instantiate (create) a C++ string on the stack like so: string str = "babbaa"; which consists of an array of 6 elements of type char: {'b','a','b','b','a','a'}; You have a C++ string of finite length consisting of only 'a' and 'b's in it. Write the following function to separate all of the 'a' and 'b' in the string so that all 'a' appear before 'b' in it: string separateLetters(string input); The above sorted string becomes, for example: cout << separateLetters("babbaa"); // outputs "aaabbb" Examples: Input: "abbbbbbbbaaaaaaa" Output: "aaaaaaaabbbbbbbb" Input: "a" Output: "a" Input: "bb" Output: "bb" Input: "ab" Output: "ab" Input: "ba" Output: "ab" Constraints and Assumptions: Input string is of finite size < 50. Input string cannot be empty or NULL. Input string only contains either 'a' or 'b' English lower-case alphabets, nothing else. Do NOT use any existing C++ sorting library for this problem.