Check if the current buying price is greater than that of the previous transaction
while ( ! transaction . isEmpty ( ) && prices [ buy ] < prices [ transaction . peek ( ) [ 0 ] ] ) { int [ ] p = transaction . peek ( ) ;