Sam
BAN USER
Comments (3)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
public static List findSum(List l1, List l2){
int sum1=0;
int sum2=0;
//Find the integer stored in list1
for (int i =0; i<l1.size();i++){
sum1= sum1*10+l1.get(i);
}
//Find the integer stored in list1
for (i =0; i<l2.size();i++){
sum1= sum1*10+l2.get(i);
}
//Find their sum
int result=sum1+sum2;
//The resultant linked list
List<Integer> resultList= new LinkedList<Integer>();
while(result!=0){
int mod=result%10;
result=result/10;
resultList.addFirst(mod);
}
return resultList;
}
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
- Sam May 30, 2013