Given *N* integers *A1, A2, …. AN*, Dexter wants to know how many ways he
can choose three numbers such that they are three consecutive terms of an
arithmetic progression.
Meaning that, how many triplets *(i, j, k)* are there such that *1 ≤ i j
k ≤ N* and *Aj - Ai = Ak - Aj*.
So the triplets
Can you just briefly describe your algorithm and time complexity? Then we
could know the problem and think about from which perspective to improve it.
Thx!
2013/7/9 abhishek sharma abhishek.p...@gmail.com
Given *N* integers *A1, A2, AN*, Dexter wants to know how many ways
he can
@Tian tanx
On Tue, Jul 9, 2013 at 5:55 PM, abhishek sharma abhishek.p...@gmail.comwrote:
Okay let me explain my approach -
1. Read numbers from the input stream and create an array of lists.. i
started with hashmaps and hashsets etc .. but they greatly killed
performance
2. Each index in
Okay let me explain my approach -
1. Read numbers from the input stream and create an array of lists.. i
started with hashmaps and hashsets etc .. but they greatly killed
performance
2. Each index in the array holds the positions of that particular index(in
the stream) in a list..(I simply
Here is the link to problem - http://www.codechef.com/problems/COUNTARI
You can see my many unsuccessful attempts in All Submissions..
Ppl with successful submission have used a superb way to just use arrays to
solve this.. I hate those einsteins!
On Tue, Jul 9, 2013 at 5:56 PM, abhishek