At a high level, candidates are allowed to use as many built-in functions as they like, as long as it doesn’t make the solution trivial.
Example: Multiply two large numbers A and B. 1 <= A, B <= 10^300
Intent: The interviewer wants to see how the number will be stored in memory (array vs. list), how operations like carry-over will be performed, etc…
Solution 1:
A language like Java has in-built libraries that make coding the solution trivial.
BigInteger x = new BigInteger(“1234…”);
BigInteger y = new BigInteger(“9876…”);
BigInteger result = x.multiply(y);
These libraries will not be allowed.
Solution 2:
On the other hand, you may use in-built libraries to store the number. Like an ArrayList.
List<Integer> digits = new ArrayList<>();
while(number > 0){
digits.add(number % 10);
number = number / 10;
}
Despite using an ArrayList over building a custom list (with node and tail pointer), this is allowed. Because the requirement of testing the candidate’s logic, coding, and communication skills are met.
Lastly, third-party libraries are a strict no for most interviews. It’s best to clarify with the interviewer when in doubt.
All the best!
Top comments (0)