Preparing for algorithm test

Have 2 weeks to prepare for a coding test. I think the topic will be timed algorithms.

I've done back and front-end coding for websites for years, know basic types, and linux commands.

But I'm completely unconfident when it comes to complex algorithms. I can only sum primes because I memorized Eratasthenes sieve after reading Sup Forums memes.

What material should I look at or practise over the next two weeks to improve my chances of doing well on one of these tests?

Other urls found in this thread:

codility.com/demo/results/demoDGRKFM-52T/
twitter.com/AnonBabble

You wouldn't need to ask this at all if you had any semblance of a math education, eg. a CS degree.

This is what happens when self-taught retards think they gamed the system and think they're on the same intellectual level as educated applicants.

fpbp

What site is that in the pic?

That assignment seems easy.
Just get it working, test the edge cases to verify it really does work, and then think about how it could work better.

I have a 2 year college degree and I'm trying to use a website to get paid $20-$30 an hour to be a code monkey.

Not trying to take your precious spot at the big 4 just trying to learn enough about algorithms to pass a competency test.

I did a codility test recently and didn't involve much more than manipulating arrays and most math involved was some triangle numbers.
You've got 3 hours to figure it out so don't worry too much and you can always use google.

Wait, is this asking what the mode of the array is?
This is piss easy.

No.
The question is this:
>If there exists some element A[i] such that the sum of every element from A[0] to A[i-1] equals the sum of every element from A[i+1] to A[n], return that i. Else, return -1.
Pathetically easy to hack something together that finds the solution even if it's slow and inefficient as fuck.

My attempt after reading your description of test:

function checkEqual(A) {
for (i = 0; i < A.length; i++) {
var tempArray = A;
secondHalf = tempArray.splice(0, arr2.indexOf(i));
sum1 = 0;
sum2 = 0;
for(j=0; j < tempArray; j++) {
sum1 += tempArray[j];
}
for(j=0; j < secondHalf; j++) {
sum2 += secondHalf[j];
}
if(sum1==sum2) return true;
}
return false;
}

for(var i = 0; i < array.length; i++)
{
count = count + array[i];
}

fuck I lost my indents ...

you don't need to prove that you can do this, it's so easy it's almost banal.

I found it difficult to even extract the problem from the text.

I imagine this is easier than the actual question I'll get. Maybe I'll try using that hacker rank site or something.

That gets you mostly the right solution but you haven't accounted for overflows (use a long instead) or the special case of the empty array.

Also it runs in O(N^2) time which the site complains about.

Do you now if it is possible to do at O(N) ?

I understand what this means but to be honest I really have to read over it again and again to actually understand that it is O(N^2).

I really want to improve on this.

I guess any loop within a loop becomes O(N^2) (?)

Here's my solution. It's almost right, but doesn't account for the empty array, but it runs in O(N) time.
class Solution {
public int solution(int[] A) {
long left = 0;
long right = 0;
// Initial right sum
for (int i = 1; i < A.length; i++)
{
right += A[i];
}
// Each time the next i is tested for equilibrium, increment left by the new left element and decrement right by the old right element
if (left == right)
return 0;
for (int i = 1; i < A.length; i++)
{
left += A[i-1];
right -= A[i];
if (left == right)
return i;
}

// Not found
return -1;
}
}


At the beginning, I test the index 0 to see if it's an equilibrium. I sum all the elements to the right of my supposed equilibrium.
If 0 doesn't work, I try 1 instead. I add the new element that is now to the left of my equilibrium (A[0]) to my left-sum, and then remove the old element that is no longer to the right of my equilibrium (A[1]) to my right-sum.
And then I just loop until all indices have been tested.

Are you blind?

OP, I took that test and it failed me because my answer didn't meet specific requirements that they didn't disclose before I submitted my answer.
Despite being correct, I got a 0 out of 100.
This is how they fail you: codility.com/demo/results/demoDGRKFM-52T/

They're not going to hire you OP, I suggest you look elsewhere.

>for (i = j; i < N; i++)
>i = j;
no you fucking retard, you misunderstood the problem.

Maybe they should have described their problem better.
This shit is basically unicru on steroids, just another way to throw your resume into the black hole.

The problem is perfectly legible, you're just thick.

>codility.com/demo/results/demoDGRKFM-52T/

>oh i'm sorry, another applicant scored an 83% on the codablity test, we're not going to move forward with your application at this time