employer cover photo
employer logo
employer logo

Clearwater Analytics (CWAN)

Engaged Employer

Clearwater Analytics (CWAN) Interview Question

How do reverse a number (like 1284 to 4821) without resorting to string manipulation?

Interview Answer

Anonymous

Aug 30, 2017

int x, y; y = 1284; while (0 != (x = mod y by 10)) { stack,push(x) y /= 10 } x = 0; while (null != (y = stack.pop())) x = (x *10) + y x == 4821