Amazon Interview Question
SDE-2sCountry: United States
Interview Type: In-Person
Number 1 : 25, represented as [2] -> [5] -> null
Number 2: 5, represented as [5] -> null
Bogus solution could be to convert the linkedlist into strings, then parse it back into integers. I'm sure this isn't what they're looking for.
public int multiplyLLNumbers(LinkedList one, LinkedList 2)
{
Node node = one.Head();
String temp = "";
while(onenode.next() != null)
{
temp += node.data.toString();
}
String temp2 = "";
node = two.Head();
while(two.next() != null)
{
temp2 += two.data.toString();
}
return (Integer.parseInt(temp1) * Integer.parseInt(temp2));
}
- mohamadreza.shakouri April 03, 2017