Header Ads Widget

Missing characters | TCS nqt solution

 Given a sentence Str. The task is to find whether the given sentence contains all letters of the English alphabet (a to z or A to Z ). If it does not, then print all missing letters of the alphabet otherwise print 0.

Note:

All characters in the given sentence should be treated as case insensitive, which means that 'A' and 'a' are to be treated as the same.

  • The output should be in alphabetic order.
  • The output should contain only lowercase alphabets. If none of the letters are missing, print 0 as output .

Example 1:

Input:

The four boxing wizard starts over the quickly 

Output:

jmp 

Explanation:

The four boxing wizard starts over the quickly" does not contains all the letters from 'a' to 'z' or 'A' to 'Z, as 'j', 'm' and 'p' .

Code (C++):-

#include <iostream>
using namespace std;

int main()
{
string s;
getline(cin,s);
int a[26]={0};
for(int i=0;s[i];i++)
{
int x=s[i];
if(x>=65 && x<=90)
x=x-65;
else if(x>=97 && x<=122)
x=x-97;
a[x]=1;
}
int flag=0;
for(int i=0;i<26;i++)
{
if(a[i]==0)
{
cout<<char(i+97);
flag=1;
}
}
if(flag==0)
cout<<0;

return 0;
}

Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-