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: | 398 Weeks Ago, 3 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
Mr. Singh recently had a breakup with his girlfriend. Depressed, Mr. Singh decides to do what he loves - coding. But he is not able to solve the problem he got his hands on
Â
which frustrates him even more. You are a friend of Mr. Singh and decide to help him solve the problem described below.
Â
Given N non negative numbers, the task is to answer M queries.
Â
Each query is as follows:
Â
Given u,v you need to find the pairwise product sum (u and v are zero indexed)
Â
auau + au+1au+1 + au+1au + au+2au
Â
+2 + au+2au+1 + au+2au + ... + avav +
Â
avav-1 + ... + avau
Â
Â
Â
Â
Â
Â
Â
Â
Input: 5 2 0 1 3 3 2 0 2 1 2 Output: 7 1
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