WAP to input 5 diff. nos. calculate the
last digit of each no. Check that
sum, if it is
prime then
display the
table of that
in tabular form ten times.
Sum of
Sum
Answers
Answered by
1
Explanation:
Above implementation takes O(d2) time as each recursive call calculates dp[] array once again. First call takes O(d), second call takes O(d-1), third call O(d-2) and so on. We don’t need to recalculate dp[] array in each recursive call. Below is the modified implementation which works in O(d) time. Where d is number of digits in input number.
Similar questions