Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 406 Weeks Ago, 2 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 17 Sep 2017 My Price 9.00

piles of cubic stones

A was playing with N piles of cubic stones of same dimensions. Each pile could be increased or decreased by adding or removing stones to it. So, he decided to put them in such a order that
the stones in ith pile is equal to the stones in (N+1-i)th, i.e., H[i] = H[N+1-i].
It is also said that the height of each pile indexed from 1 to N/2 are in single step increasing order and then from N/2 to N it decreases in single step. Output the number of piles on which he should work to make the required pattern

Required pattern of piles are shown in two figures 1 and 2.
Figure 1 shows the pattern when N is 8 (i.e., even).
Figure 2 shows the pattern when N is 9 (i.e., odd).

Click here for figure 1 and 2

Input

  • First line contains T denoting the number of test cases.
  • Next T lines contains N the numbers of piles.
  • Next line contains N space separated heights of each pile.

Output

  • Print minimum number of piles on which he should increase or decrease the stones so that he obtains the required pattern.

Constraints

  • 1 T 100
  • 1 N 100000
  • 1 H[i] 100000

Example

Input: 2 4 1 2 2 1 5 1 2 1 3 1 Output: 0 2

Explanation

Case 1 :Here all the piles are in increasing and then decreasing order of single step.So no pile need to be worked upon.

Case 2 :Here we need to make the given input of heights in 1 2 3 2 1. For that we need to remove and add only in 4th and 3rd pile respectively.So the answer is 2.

Answers

(5)
Status NEW Posted 17 Sep 2017 12:09 PM My Price 9.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)