Amisha328 / Company-Specific-Coding-Questions

1 stars 0 forks source link

TEST CASE(S) for which this code will give WRONG ANSWER #1

Open Amisha328 opened 2 years ago

Amisha328 commented 2 years ago

In the main method, read a String (which may have alphabets along with numeric digits) and print the number of vowels and consonants (any alphabet apart from vowel is a consonant) present in the given String. Note: The output should be printed in the same format as mentioned in the sample output. Number of Vowels: n Number of Consonants: m

Find Code here

Suggest some test case(s) for which this code will give wrong answers. Any suggestions for improvement of the code will be acknowledged.

zafarD commented 1 year ago

Maybe it is about time complexity or space complexity. even if I trim the string, test cases not passed. Here is another approach from me -> s = s.replaceAll("[\d\s\p{Punct}]",""); vowel = s1.replaceAll("(?i)[^aeiou]","").length(); conso = s1.replaceAll("(?i)[aeiou]","").length();

if you already figured out, please tell me.