XXX
BAN USER- 0of 0 votes
AnswersYou have to take a string or a line as an input from the user and apply two rules to it:
- XXX in United States
1. if the letter is a vowel like 'e'...convert it to 'E' and if its a "E"..convert it to 'e'...same for all the vowels. However the first letter has to be Capital.
2. if its a consonant, let it be as it is but if the consonant is the first letter of the sentence make it capital
For eg: bEes ARe Busy...will become
BeEs arE bUsy| Report Duplicate | Flag | PURGE
- 0of 0 votes
AnswersIf you guys have played othello or reversi, this is the game that they asked, but all the moves for red and black were passed in a boolean array to us. We just have to find who is the winner of the game, if for a sequence of 3 u get 1 point, for a sequence of 4 u get 2 points, for sequence of 5 u get 3 and so on.. Sequences can be horizontal,vertical or diagonal...the output of the program should be who won the game...red or black.
- XXX in United States| Report Duplicate | Flag | PURGE
public class Isomorphic {
public static boolean isIsomorphic(String a, String b) {
if(a.length() != b.length()) return false;
if(a == null || b == null) return false;
Map<Character,Character> mappings = new HashMap<Character,Character>();
for(int i = 0; i < a.length(); i++) {
char key = a.charAt(i);
char currentMapping = b.charAt(i);
if(mappings.containsKey(key)) {
char prevMapping = mappings.get(key);
if(prevMapping != currentMapping) return false;
}
else if(mappings.containsValue(currentMapping)) return false;
else mappings.put(key, currentMapping);
}
return true;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(Isomorphic.isIsomorphic("foo", "app"));
System.out.println(Isomorphic.isIsomorphic("foo", "pap"));
System.out.println(Isomorphic.isIsomorphic("foe", "app"));
System.out.println(Isomorphic.isIsomorphic("ab", "ba"));
}
}
- XXX August 04, 2014