Frage im Vorstellungsgespräch bei Barco

Reverse a string of words "Hi I am John" as "John am I Hi" without using array functions like split , reverse or join?

Antworten zu Vorstellungsgespräch

Anonym

19. Aug. 2017

tail recursive algo

Anonym

3. Sept. 2019

str1 = "Hi abc tm" len1 = len(str1) ln = len1 space = " " str3 = [] cnt = 0 while len1 !=0: if str1[len1-1]!=" ": len1 = len1-1 cnt = cnt + 1 if str1[len1-1]==" ": len2 = ln-cnt while len2 != ln: if str1[len2] != " ": print(str1[len2],end="") len2 = len2 + 1 else: break print(space,end="") cnt = cnt + 1 len1 = len1-1 len2 = ln-cnt while len2 != ln: if str1[len2] != " ": print(str1[len2],end="") len2 = len2 + 1 else: break

Anonym

19. Nov. 2020

const str = 'Hi I am John" as "John am I Hi'; const reverseString = function() { let temp = ""; for (let i = str.length; i >= 0; i--) { temp += str.charAt(i); } return temp; }; console.log(reverseString());

Anonym

19. Nov. 2020

In Core Javascript const str = 'Hi I am John" as "John am I Hi'; const reverseString = () => { let temp = ""; for (let i = str.length; i >= 0; i--) { temp += str.charAt(i); } return temp; }; console.log(reverseString());

Anonym

8. Mai 2019

a = "Hi I am John"; ind =[]; for(k=0; k