Consider the following decision problem: given two lists of positive integers a1,a2,…,an and b1,b2,…,bm the task is to decide if aa⋅⋅⋅an21<bb⋅⋅⋅bm21.

- Is this problem in the class P?
- If yes, then what is the algorithm solving it in polynomial time?
- Otherwise, what is the fastest algorithm that can solve it?

Update:

- I mean polynomial type with respect to the size of the input, i.e. total number of digits in all ai,bi.
- pqrs=p(q(rs)),
not((pq)r)s.

**Answer**

Recently I asked a very similar question at Mathematica.SE.

I assume you know it, because you participated in the discussion.

Leonid Shifrin suggested an algorithm that solves this problem for the majority of cases, although there were cases when it gave an incorrect answer. But his approach seems correct and it looks like it is possible to fix those defects. Although it was not rigorously proved, his algorithm seems to work in polynomial time. It looks like it would be fair if he got the bounty for this question, but for some reason he didn't want to.

So, this question is not yet settled completely and I am going to look for the complete and correct solution, and will start a new bounty for this question once the current one expires. I do not expect to get a bounty for this answer, but should you choose to award it, I will add it up to the amount of the new bounty so that it passes to whomever eventually solves this question.

**Attribution***Source : Link , Question Author : Vladimir Reshetnikov , Answer Author : Community*