I headed over and liked the design and thought I'd take the demo test. I recommend you give it a go and come back after that.
It was a neat and easy to understand interface. I selected C as it's my weapon of choice for everything except for applications that need extensive string handling (in which case the String class makes bothering with Java worthwhile).
They had a fair problem and a suboptimal solution as a framework. After coding my most intuitive solution (for those who tried the demo, getting the righthand side total then:
for(i=0;i<n;i++){
rsum -= arr[i];
if (lsum == rsum) return i;
lsum += arr[i]; }
To avoid arithmetic overflow, the array consists of doubles to be on the safe side. I overlooked this the first time in.
Anyway, in the 30mins I got it except for the overflow, which I went back and checked that it worked. I wish there were a few more tests like this as work doesn't exercise all my c muscles :) Props to Codility hopefully a thing of the future.
No comments:
Post a Comment