The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 406 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
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: 2 4 1 2 2 1 5 1 2 1 3 1 Output: 0 2
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.
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