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: | 399 Weeks Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Arshu and Aman are two friends who love coding. Arshu is boasting about how he can solve questions based on segment trees in no time. Aman decides to teach him a lesson and gives him a problem. Aman gives him an array of N numbers. Arshu has to fulfil M. operations.
Each operation has one of the following two types:
U X Y : Update the value at the Xth index of the array with Y. Q X C : Calculate the length of the longest subarray that starts at Xth index and satisfy following inequality A[X]-C = V =A[X] + C Where V is any value from the chosen subarray.
Arshu is having a hard time solving the problem and he doesn't want to lose to Aman. Naturally, he turns to his other coding friend which happens to be you.Help Arshu for this challenge.
Â
Â
Â
Â
Â
Â
Â
Â
Input: 5 5 1 2 3 4 5 Q 1 3 U 2 6 Q 1 3 Q 1 -1 Q 1 6 Output: 4 3 1 0 -1 -1 5 5
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