demonix
BAN USER
Questions (2)
Comments (3)
Reputation 300
- 0of 0 votes
AnswersWrite a function that would print all positive numbers smaller than n that can be expressed as the sum of two cubes in two different ways. Bonus: calculate the complexity of that function.
- demonix in United States
For example, 1729 is one such number because 1729 = 1^3 + 12^3 = 9^3 + 10^3.| Report Duplicate | Flag | PURGE
Google Software Engineer Intern - 0of 0 votes
AnswersWrite code that would parse an expression that is similar to BASH brace expansion. Best illustrated with an example: the expression "(a,b,cy)n,m" would be parsed into an array of the following strings:
- demonix
an
bn
cyn
m
You can assume that the input will always be valid.
Hint: the expression can nest. Therefore, "((a,b)o(m,n)p,b)" parses into:
aomp
aonp
bomp
bonp
b| Report Duplicate | Flag | PURGE
Google Software Engineer Intern String Manipulation
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
The interviewer didn't specify whether negative cubes are allowed - in retrospect, figuring that out might have been part of the problem.
- demonix February 19, 2015