Shankey
BAN USERStep1 : Pour from 3L to 5L.
Step2 : Now 5L has 3L and 3L flask empty. Fill the 3L flask and pour into 5L flask.
Step3: Now 5L flask is full and 3L flask has 1L remaining.
Step4: Throw the water from 5L flask and get the 1L from 3L flask.
Step5: Fill the 3L flask with water and pour into 5L which already has 1L in it. Altogether it makes 4L in flask 5L.
:) I just tried to get the tokens by split method of String. After getting the tokens I got hold of each token and started reversing the alphabets in that particular token. I mean the last alphabet comes to first and so on. Used spaces(whitespace) for each token to be separated. trim() method was used to remove any extra whitespaces .
- Shankey April 25, 2014My code in Java. Complexity wise its not good i guess. Anyways this is what i thought.
int lengthStr;
int i;
String strNew = "";
char[] cs = new char[10];
String str = "I am a human being";
System.out.println("Original String :"+str);
String[] strArray = str.split("\\s");
for(String s : strArray){
lengthStr = s.length();
strNew = strNew + " ";
for(i=0; i<s.length(); i++){
cs[i] = s.charAt(lengthStr-1);
lengthStr--;
strNew = strNew + cs[i];
}
}
System.out.println("Reversed String :"+strNew.trim());
}
Take a candy from the Mix jar. If its a lemon then its definitely a lemon jar labelled as Mix coz the other two jars Mix and Banana wud be wrongly labelled as Banana and Lemon respectively else we wont get all wrongly labelled jars. Same goes for if the Mix jar has a banana candy in the first go.
- Shankey April 27, 2014