-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGood or Bad string.java
More file actions
48 lines (45 loc) · 1.01 KB
/
Good or Bad string.java
File metadata and controls
48 lines (45 loc) · 1.01 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
// User function Template for Java
class Solution {
static int isGoodorBad(String S) {
// code here
int count=0;
int count2=0;
int i=0;
while(i<S.length())
{
char ch=S.charAt(i);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
{
count++;
if(count>5)
{
return 0;
}
count2=0;
}
else if(ch=='?'){
count++;
count2++;
if(count>5)
{
return 0;
}
else if(count2>3)
{
return 0;
}
}
else
{
count2++;
if(count2>3)
{
return 0;
}
count=0;
}
i++;
}
return 1;
}
};