Tech Mahindra 2021 Non-SDE (3-6 Dec) Hands-on Coding Question Asked with Solution
Frequency Count Question with Solution: Frequency Count In C++
// Solved By Pappu Kumar (Coder Guy)
#include <bits/stdc++.h>
using namespace std;
string helper(string s)
// Solved By Pappu Kumar (Coder Guy)
{
int arr[26]={0}; // there are 26 alphabets
in the english char
for(int i=0;i<s.length();i++) // loop through
the input string
{
arr[s[i]-97]++; //
to come back with the 0 position
}
string result="";
for(int i=0;i<26;i++) // for character
count with loop
{
if(arr[i]>0) // if char is present
{
char ch = 97+i; // add the value of
ASCII value of i = 1 - taking b
result+=ch;
result+=to_string(arr[i]);
}
}
return result;
}
int main() {
string s;
cin>>s;
cout<<helper(s);
return 0;
}
// Solved By Pappu Kumar (Coder Guy)
Input: phqgh
Output: g1h2p1q1
In Python
Coming Soon.....
VIDEO
Also Read,
Tech Mahindra 2021 Non-SDE (3-6 Dec) Hands-on Coding Question Asked with Solution | Part: 1 - BitWise Operation
Tech Mahindra 2021 Non-SDE (3-6 Dec) Hands-on Coding Question Asked with Solution | Part: 2 - Geometric Progression
Tech Mahindra 2021 Non-SDE (3-6 Dec) Hands-on Coding Question Asked with Solution | Part: 3 - Caesar Cipher
Tech Mahindra 2021 Non-SDE (3-6 Dec) Hands-on Coding Question Asked with Solution | Part: 4 - Frequency Count
Also, apply for jobs ,
Google (STEP) Internship 2021
Tech Mahindra Foundation Intern 20/2021
Cadence Off-Campus Drive 20/2021
H-Town Technologies Off-Campus Drive 20/2021
JK Technosoft Off-Campus Drive 2021
Techjockey Off-Campus Drive 2019-2020
Swiggy Off-Campus Drive 2018-2021
Microsoft Research Fellows Program 2020-2021
TCS Off-Campus Drive 2021
Tips to Follow to Crack Tech Mahindra Exam 2021
CTS - Cognizant 96 Important Interview Questions 2021
TCS Ninja and Digital 2021 All Interview Questions
Hexaware technical interview 2021
Stay tuned with www.freshersocjob. com to receive more such updates on recruitment. Join our Telegram Channel and Join our WhatsApp Group To get Instant updates for All Recruitment Internships and Off-Campus of 2021 Pass-Out Batch and Other Batch.
Comments
Post a Comment