-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidWord_3136.java
More file actions
31 lines (29 loc) · 930 Bytes
/
ValidWord_3136.java
File metadata and controls
31 lines (29 loc) · 930 Bytes
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
package Daily_Problem;
public class ValidWord_3136 {
public static boolean isValid(String word) {
int[] arr = new int[2];
for (int i = 0; i < word.length(); i++) {
char c = word.charAt(i);
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O'
|| c == 'U') {
arr[0]++;
} else if (Character.isLetter(c))
arr[1]++;
else if (Character.isDigit(c)) {
} else
return false;
}
int count = 0;
for (int i : arr) {
if (i >= 1)
count++;
}
if (word.length() > 2)
return count == 2;
return false;
}
public static void main(String[] args)
{
System.out.println(isValid("234Adas"));
}
}