1,387 views
1 votes
1 votes
Let T(n) be a function which takes an integer n having k digits as input. The function T(n) finds the maximum number of perfect squares possible by removing either least significant digit or the most significant digit.

For example, consider the number 32492, T(32492) = 3 via sequence
32492→3249→324→24→4
You are given a function IS_SQUARE(a) which tells you whether the integer a is a perfect square or not.
If the time complexity for IS_SQUARE(a) is O(1), what is the time complexity to compute T(n)?

Please log in or register to answer this question.

Related questions

0 votes
0 votes
1 answer
1
JPranavc asked Nov 22, 2017
415 views
What will be the output? for foo(4) 4332221234 4332221324 43222214 4332211223
2 votes
2 votes
2 answers
3
Rohan Mundhey asked Nov 6, 2016
423 views
Consider the following recursive functionint gun(int i){if(i>4)return(2+gun(i-5) + gun(i-2));return 1;}Find the value returned form the gun(15) ?