Problem · Linked List
EasyCiscoINTERNOA
See Cisco hiring insights

Problem statement

Write an algorithm to add the numbers and print them as a list.

Input

The first line of input consists of an integer- list1_size, representing the size of the first list (N). The second line consists of N space-separated integers representing the elements in the first list. The third line of input consists of an integer- list2_size, representing the size of the second list (M). The last line consists of M space-separated integers representing the elements in the second list.

Output

Print K space-separated integers representing the digits in reverse order which are the sum of both the numbers.

🫧𓇼𓏲*ੈ✩Credit to Charlotte‧₊˚🎐

Function

addNumbers(list1: List<Integer>, list2: List<Integer>) → List<Integer>

Examples

Example 1

list1 = [2, 4, 6]list2 = [8, 0, 9]return = [0, 5, 5, 1]

The given lists are [2,4,6], [8,0,9], so the two numbers are '642' and '908'. The sum of both the numbers is 642+908=1550. So the output is [0, 5, 5, 1].

Constraints

🍐🍐

More Cisco problems

drafts saved locally
public List<Integer> addNumbers(List<Integer> list1, List<Integer> list2) {
  // write your code here
}
list1[2, 4, 6]
list2[8, 0, 9]
expected[0, 5, 5, 1]
checking account