Consonant Counting Problem Statement

Given a string STR comprising uppercase and lowercase characters and spaces, your task is to count the number of consonants in the string.

A consonant is defined as an English alphabet character that is not a vowel (a, e, i, o, or u). Examples of consonants include b, c, d, f, etc.

Example:

Input:
STR = 'Coding Ninjas'
Output:
8
Explanation:

The given string contains 8 consonants: 'C', 'd', 'n', 'g', 'N', 'n', 'j', 's'. These characters are not part of the vowel set.

Constraints:

  • 1 ≤ T ≤ 50
  • 1 ≤ Length of STR ≤ 104
  • The string consists of uppercase and lowercase letters and spaces.
  • Time Limit: 1 sec
AnswerBot
4mo

Count the number of consonants in a given string containing uppercase and lowercase characters and spaces.

  • Iterate through each character in the string and check if it is a consonant (not a vowel).

  • Keep...read more

Help your peers!
Select
Add answer anonymously...

Optum Global Solutions Software Engineer interview questions & answers

A Software Engineer was asked 3mo agoQ. What is the process for implementing a linked list?
A Software Engineer was asked 3mo agoQ. What is an IoC (Inversion of Control) container?
A Software Engineer was asked Q. How can you arrange an array in decreasing order without using extra space, a so...read more

Popular interview questions of Software Engineer

A Software Engineer was asked 3mo agoQ1. What is the process for implementing a linked list?
A Software Engineer was asked Q2. How can you arrange an array in decreasing order without using extra space, a so...read more
A Software Engineer was asked Q3. Given the head of a singly linked list, sort the list using insertion sort, and ...read more

Top HR questions asked in Optum Global Solutions Software Engineer

A Software Engineer was asked 4mo agoQ1. Rate your proficiency in the technologies listed in your skills.
A Software Engineer was asked Q2. Why do you want to join?
A Software Engineer was asked Q3. Explain your projects and work.
Optum Global Solutions Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits