Separating merged array of arithmetic and geometric series
Posted
by
user1814037
on Stack Overflow
See other posts from Stack Overflow
or by user1814037
Published on 2012-12-07T07:47:16Z
Indexed on
2012/12/08
23:04 UTC
Read the original article
Hit count: 177
My friend asked me an interseting question.
Given an array of positive integers in increasing order. Seperate them in two series, an arithmetic sequence and geometric sequence. The given array is such that a solution do exist.
- The union of numbers of the two sequence must be the given array.
- Both series can have common elements i.e. series need not to be disjoint.
- The ratio of the geometric series can be fractional.
Example:
Given series : 2,4,6,8,10,12,25
AP: 2,4,6,8,10,12
GP: 4,10,25
I tried taking few examples but could not reach a general way. Even tried some graph implementation by introducing edges if they follow a particular sequence but could not reach solution.
© Stack Overflow or respective owner