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.
/*bm represents ad+M and d is just ad. Max is the longest subsequence so far and cur is the current subsequence's length*/deflongseq(a:List[Int],max:Int,cur:Int,bm:Int,d:Int):Int={amatch{caseNil=>returnmaxcaseh::t=>if(h<=bm&&h>=d){if(cur<max){returnlongseq(t,max,cur+1,bm,d)}else{returnlongseq(t,cur+1,cur+1,bm,d)}}else{returnlongseq(t,max,0,bm,d)}}}
This is my scala solution but it keeps timing out for every test case beyond test case 4. I can't think of any way to optimise it and I'm not sure if I might have a problem with the way I'm doing the i/o instead..
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Stock Prediction
You are viewing a single comment's thread. Return to all comments →
This is my scala solution but it keeps timing out for every test case beyond test case 4. I can't think of any way to optimise it and I'm not sure if I might have a problem with the way I'm doing the i/o instead..