Pregunta de entrevista de Booking.com

Given a integer , return corresponding ASCII char representation without using language building in feature. ex. input interger 1234, return "1234" in string or characters

Respuestas de entrevistas

Anónimo

10 de oct de 2017

function numberToString(n){ if(n/10 < 1) return "" + n //edge case return numberToString(Math.round(n/10)) + "" + n%10 //I concatenate with the empty string just to convert the number to a string without using built-in toString() }

1

Anónimo

19 de oct de 2017

def itoa(num): array = [] while num > 0: rem = num % 10 array.append(chr(rem + 48)) num = num // 10 array.reverse() return ''.join(array)

1

Anónimo

19 de dic de 2017

num = 1234 result='' while (num > 0): rem = num % 10 result = str(rem) + result num = int(num / 10) print(result)

Anónimo

4 de jul de 2019

def int2str(num: Int): String = { if (num > 0) int2str(num / 10) + (num % 10).toString else "" }

Anónimo

4 de jul de 2019

def int2str(num: Int): String = { if (num > 0) int2str(num / 10) + (num % 10 + 48).toChar else "" }

Anónimo

8 de oct de 2016

num_to_convert = 10 # or any INT number converted_str = '' while True: remainder = num_to_convert % 10 converted_str += str(remainder) if (num_to_convert // 10) <= 0: break else: num_to_convert //= 10 print(converted_str[::-1])

Anónimo

15 de jun de 2016

while (num > 0) { int rem = num % 10; result += rem; num = num / 10; } string x = Reverse(result); return x;

3