We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
New on this site and having hard time with this task. Luckily found your comment and found my mistake. here's my short version of yours
<?php$_fp=fopen("php://stdin","r");$_fp2=fopen('php://stdout','w');/* Enter your code here. Read input from STDIN. Print output to STDOUT */fscanf($_fp,"%d %d",$n,$m);$r=[];for($i=0;$i<$m;$i++){fscanf($_fp,'%d %d %d',$a,$b,$k);$r[$a]+=$k;$r[$b+1]-=$k;}ksort($r);$max=$sum=0;foreach($ras$val){$sum+=$val;if($sum>$max){$max=$sum;}}fwrite($_fp2,$max);?>
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
New on this site and having hard time with this task. Luckily found your comment and found my mistake. here's my short version of yours