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?
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.
Samuel Gonzalez
fpbp
Evan Cruz
What site is that in the pic?
Joshua Wright
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.
Ian Cruz
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.
Alexander Gutierrez
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.
Hudson Thompson
Wait, is this asking what the mode of the array is? This is piss easy.
Carter Kelly
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.
Bentley Richardson
My attempt after reading your description of test:
for(var i = 0; i < array.length; i++) { count = count + array[i]; }
Liam Smith
fuck I lost my indents ...
Jason Miller
you don't need to prove that you can do this, it's so easy it's almost banal.
Isaac Johnson
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.
Nathaniel Evans
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.
Connor Hernandez
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.
Cameron Adams
I guess any loop within a loop becomes O(N^2) (?)
Hudson Bennett
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.
Landon Gutierrez
Are you blind?
Austin Richardson
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.
Brody Roberts
>for (i = j; i < N; i++) >i = j; no you fucking retard, you misunderstood the problem.
Camden Turner
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.
Alexander Perez
The problem is perfectly legible, you're just thick.