Dropbox Interview Question

Given a string such as "123" or "67", write a function to output the number represented by the string without using casting.

Interview Answers

Anonymous

Sep 9, 2013

Java Code public class StringToInt{ public static void main(String[] args){ String str = args[0]; int length = str.length(); length --; int num = 0; for(int i = length; i >= 0; i --){ num += (str.codePointAt(i) - 48) * Math.pow(10, length - i); } System.out.println(num); } }

Anonymous

Dec 15, 2020

There's a lot of elements to typically cover in these questions, clarifications, scoping, making sure you're answering the actual question the interviewer is looking for you to answer, etc. Could be worth doing a mock interview with one of the Prepfully Dropbox Software Engineering Intern experts... they've worked in the role so they clearly know how to get through the interview. prepfully.com/practice-interviews