Senior software engineer interview questions shared by candidates
Write a function that divides one number by another, without using the division operator, and make it better than O(n).
This can be done in a recursive function, the following code is in Python. # get result of a/b without using a "divide" operator def div(a,b): if a < b: return 0 else: return div(a-b, b)+1 This is how human being do the division naturally, however, the running time of this is O(n/m), where n is the size of a, and m is the size of b, which means, O(n/m) is guaranteed to be less than O(n), when m is larger than 1. -Maxim
The answer above is still O(n). We can use binary search and find the answer in the interval [1,a] and use multiplication operator.
Totally agree with Vasil. Other option: Long Division Algorithm. O(log n) anyway.
Write Fizz-Buzz in C++. Now make all the stupid constant-time optimizations you can think of to it. Formally: given an int, return “fizz” if it’s a multiple of 3, “buzz” if it’s a multiple of 5, or “fizz buzz” if it’s a multiple of both. It it isn’t a multiple of 3 or 5, return “”. Then find stupid ways to over-optimize it, such as using no if-statements.
See Interview Questions for Similar Jobs
- Software Engineer
- Software Developer
- Software Development Engineer
- Senior Software Developer
- Software Engineer III
- Software Development Engineer II
- Senior Software Development Engineer
- Java Developer
- Staff Software Engineer
- Principal Software Engineer
- Software Development Engineer I
- Project Manager
- Product Manager
- Senior Developer