Posts

Showing posts from March, 2022

Encrypt the string - 1 Solution in cpp

Encrypt the string - 1 Solution in cpp GfG  problem solution in cpp PROBLEM STATEMENT:-  Bingu was testing all the strings he had at his place and found that most of them were prone to a vicious attack by Banju, his arch-enemy. Bingu decided to encrypt all the strings he had, by the following method. Every substring of identical letters is replaced by a single instance of that letter followed by the number of occurrences of that letter. Then, the string thus obtained is further encrypted by reversing it. INPUT OPUPUT EXPLANATION:- Example 1: Input: s = "aabc" Output: 1c1b2a Explanation: aabc Step1: a2b1c1 Step2: 1c1b2a code;- // { Driver Code Starts #include<bits/stdc++.h> using namespace std;  // } Driver Code Ends class Solution{     public:     string reverse(string s){         int i=0;         int j=s.length()-1;         while(i<j){             ...