请推荐杀灭蚂蚁的方法# gardening - 拈花惹草
R*y
1 楼
You have two numbers represented by a linked list where each node contains a
single digit. The digits are stored in reverse order. Write a function to
add two numbers and return another linked list.
题目来自Career up 150. 另有一个followup, linked list 储存数字为正常顺序,同
样求和。
书上给的解法是直接进行数位的加减,然后将新的数字输入到linkedlist.
这一题,我直接的想法是利用stack和queue 将数字取出来重新包装成int,完成加法后
,再输入回linkedlist。
希望有大牛帮忙比较一下两种思路的优劣。
single digit. The digits are stored in reverse order. Write a function to
add two numbers and return another linked list.
题目来自Career up 150. 另有一个followup, linked list 储存数字为正常顺序,同
样求和。
书上给的解法是直接进行数位的加减,然后将新的数字输入到linkedlist.
这一题,我直接的想法是利用stack和queue 将数字取出来重新包装成int,完成加法后
,再输入回linkedlist。
希望有大牛帮忙比较一下两种思路的优劣。