Pergunta de entrevista da empresa Epic

replace the "a" in a sentence to "the"

Respostas da entrevista

Sigiloso

27 de out. de 2011

this is how i would do it, in pseudocode: create a StringBuffer to add individual characters and eventually return. string to char array iterate through the char array if a character is 't', check the next chars to see if they are 'h' and 'e' respectively. if so, just add 'a' and jump to the proper index in the array if character isn't 't', just add to the StringBuffer return StringBuffer to string or some kind of while using indexOf('the'), but using a StringBuffer instead of lots of String concatenations

2

Sigiloso

28 de out. de 2011

Simply use string::find and string::replace functions.

Sigiloso

17 de jan. de 2012

NO need to use String.find(). just use string.replaceAll("the","a");