-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountVowel.java
More file actions
69 lines (55 loc) · 1.42 KB
/
CountVowel.java
File metadata and controls
69 lines (55 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.vinay.practice.lc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
/*
* A vowel substring is a substring that only consists of vowels ('a', 'e', 'i', 'o', and 'u')
* and has all five vowels present in it.
*
* Given a string word, return the number of vowel substrings in word.
*
* Input: word = "aeiouu"
* Output: 2
*/
public class CountVowel {
public static void main(String[] args) {
// TODO Auto-generated method stub
String word = "cuaieuouac";
StringBuilder sb = null;
HashSet<String> vowelWords = new HashSet<String>();
for(int i=0; i<word.length(); i++) {
sb = new StringBuilder();
for(int j=i; j<word.length(); j++) {
if(checkVowel(word.charAt(j))) {
System.out.println(j);
sb.append(word.charAt(j));
} else {
break;
}
}
if(!sb.toString().isEmpty() && checkAllVowel(sb.toString())) {
vowelWords.add(sb.toString());
System.out.println(sb.toString());
}
}
}
public static Boolean checkVowel(char c) {
if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' ) {
return true;
}
return false;
}
public static Boolean checkAllVowel(String str) {
String[] vowel = new String[] {"a", "e", "i", "o", "u"};
if(str.length() >= 5) {
int counter = 0;
for(int i=0; i<str.length(); i++) {
}
}else {
return false;
}
return false;
}
}