Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public boolean detectCapitalUse(String word) {
- int n = word.length();
- int count =0; //uppercase
- for(int i =0; i <n;i++){
- if(Character.isUpperCase(word.charAt(i))){
- count++;
- }
- }
- //cases
- if(count == n || count ==0){
- return true;
- }
- if(Character.isUpperCase(word.charAt(0)) && count ==1){
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement