Interview Question
Entry Level Cognitive Software Engineer Interview
-
IBMThey asked me to extract words from the parse tree. e.g. ((NJ (NN James) XX is) (AJ tall)) -> James is tall. Another question is to reverse a string an capitalize all the starting positions of words and lower case all the ending positions of words. e.g. Hello World -> Dlrow Olleh
Interview Answers
6 Answers
After the online interview how many more rounds of interviews were there?
More rounds? on
def reveseCapitalize(s): s = s.lower() s = s[::-1] s = s.title() return s print(reveseCapitalize('Hello World'))
Rain Lawson on
The above doesn't work if there's a possibility of letters besides the first being capitalized
Anonymous on
def reveseCapitalize(s): s = s[::-1] s = ' '.join(w.capitalize() for w in s.split()) return s print(reveseCapitalize('Hello World!'))
Sri Phani Gorti on
public static String reverese_capital_firstword(String word){ String val = ""; StringBuilder builder = new StringBuilder(); String[] holder = word.split(" "); for(int i = holder.length -1; i >= 0; i--){ String[] word_splited = holder[i].toLowerCase().split(""); String sec_holder = ""; for (int j = word_splited.length -1; j >=0 ; j--){ if(j == word_splited.length-1){ sec_holder += word_splited[j].toUpperCase(); }else{ sec_holder += word_splited[j]; } } if(val.equals("")){ val += sec_holder; }else{ val += " "+sec_holder; } } return val; }
Badjong Lucillo on
Can You please post other questions
Anonymous on