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
ACP Pradyumn is on his way to catch the mastermind behind the Hyderabad bomb blasts.
Â
The mastermind, on the other hand, challenges the ACP by generating a sequence of numbers for him.
Â
There is a sequence of n numbers, which can be both positive and negative. The task is to find the number of continuous sequence of numbers such that their sum is zero.
For example if the sequence is: 5, 2, -2, 5, -5, 9 There are 3 such sequences 2, -2 5, -5 2, -2, 5, -5
Since the ACP is having difficulty in solving the problem, he asks for your help. Your goal is to find number of such sequences to help the ACP in catching the terrorist.
Â
Â
First line contains T - number of test cases Second line contains n - the number of elements in a particular test case. Next line contain n elements, ai (1
Â
The number of such sequences whose sum if zero.
Â
1
Input: 2 4 0 1 -1 0 6 5 2 -2 5 -5 9 Output: 6 3
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