USE C++!! Given a string you need to print all possible strings that can be made by placing spaces (zero or one) in between them. The output should be printed in sorted increasing order of strings....



USE C++!!


Given a string you need to print all possible strings that can be made by placing spaces (zero or one) in between them. The output should be printed insortedincreasing order of strings.


You don't need to read input or print anything. Your task is to complete the functionvector
permutation(string S) which takes the string S as input parameters and returns thesorted arrayof the string denoting the different permutation(DON'T ADD '(' and ')' it will be handled by the driver code only).



Expected Time Complexity: O(2^n)

Expected Auxiliary Space: O(1)




CONSTRAINTS:

1 < |s|=""><>
S only containslowercase and Uppercase English letters.



ATTACHED BELOW ARE THE REQUIRED DRIVER CODES


1- // { Driver Code Starts<br>2 #include <bits/stdc++.h><br>3 using namespace std;<br>4<br>6 // } Driver Code Ends<br>7- class Solution{<br>8 public:<br>vector<string> permutation(string S){<br>// Code Here<br>10<br>11<br>12<br>}<br>14 };<br>13<br>15<br>16 - // { Driver Code Starts.<br>17<br>18 - int main(){<br>19<br>int t;<br>20<br>cin>>t;<br>while(t--){<br>string S;<br>cin>>5;<br>vector<string> ans;<br>Solution obj;<br>21<br>22<br>23<br>24<br>25<br>26<br>obj.permutation(S);<br>ans<br>for (int i=0;i<ans.size();i++){<br>cout<<

Extracted text: 1- // { Driver Code Starts 2 #include 3 using namespace std; 4 6 // } Driver Code Ends 7- class Solution{ 8 public: vector permutation(string S){ // Code Here 10 11 12 } 14 }; 13 15 16 - // { Driver Code Starts. 17 18 - int main(){ 19 int t; 20 cin>>t; while(t--){ string S; cin>>5; vector ans; Solution obj; 21 22 23 24 25 26 obj.permutation(S); ans for (int i=0;i<><><")"; }="" cout=""><« endl; 27- 28 29 30 31 32 } 33 // } driver code ends endl;="" 27-="" 28="" 29="" 30="" 31="" 32="" }="" 33="" }="" driver="" code="">
Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here