Codility( is web application which helps employer to filter best programmers from average programmers. Codility Limited is based in London, UK.

Codility saves time of software talent recruiters by filtering out job candidates who cannot write correct program.

Codility administers short programming tests and checks whether solutions are rock solid.

During recruitment process employers can use Codility and choose different programming tests which can be emailed to candidates. Candidates can solve the problem on web browser and can submit the solution by clicking the submit button. Once solution is submitted Codility performs range of testing on the source code and try to evaluate which canidate solved the problem in best way. Normally you can write the soultion for interview test under 20 lines of code but if your algorithum is not robust then it will fail the Codility test. During validating the source code, Coditiy internal application will test your program with both valid and invalid data. On top of that it also measures how long your algorithum is taking to process large amount of input. Normally during test you can see the requirement for Bio O notion on the screen such as O(1), O(N) etc. The good thing about codility is that candiate can use the language they are comfortable with.

Now you must be wondering why i am writing about this company. Well during one of my job interview i was asked to do online test on Codility website, I thought that it will be multiple choice question and it will be very easy to pass the test. Once i reached home, i opened Codility website and decided to try few of their sample questions. For one of their sample question i was not able to understand the question so i skipped to the next one. Well next question i understood but i did not realized that i will be tested on speed of my algorithum. So i started writing code for sample test in Java, it was so difficult to write code on their browser because it breaks all the indentation and curly brackets; are placed on the wrong places. If codes are not indented nicely then i can’t even read my own code 🙂 . Well after finishing the solution i submitted to see my result. Guess what? I FAILED the test. The test result failed me on timing. At that stage i got so nervous, that i decided to try another sample test and i was not able to solve it within time limit( I guess sample test need to be solved within 30 min, I can’t remember exact timing). On that night i could not sleep, i felt like i am hopeless and not able to write simple line of code.

Next day i asked my friend to try Codility sample test and he failed as well, well now i was relieved 🙂 . Next day i asked one of top student of my class to try sample test and he failed in timing test as well. I was really scared that i will not get face to face interview with this company.But anyway i decided to try the actual test whose link was emailed to me. Before starting my test i opened my java IDE and clicked link to begin my test.My first question was to reverse a String, i was so happy after looking at that question and finished it quickly. But since i was scared,i started testing my code with different data. My second question was about “Nested Parentheses” where you will write a code to find if parentheses are properly nested on not. If your have brackets like this ” ( ) ” or ” ( ( ) ) ( ) ” then it means that it is properly nested but if you have bracket like this ” ( ( ) ” or ” ) ) ) ( ( ( ” then it means that its not properly nested. And i was supposed to handle String of length 200,000 characters.

It took me rougly 10 minute to plan how i am going to solve the problem and i came with following algorithum.

  1. Remove all spaces from String.
  2. Count the length of String, and find out if its odd or even number. If string is odd number then it is not properly nested.
  3. If String is even number then run a loop and remove all matching ” ( ) ” character from the string.
  4. Now check the length of String, if length is zero then String is properly nested else its not.

Once i figure out the algorithum, i started writing my code. Below is solution of my code.

class Solution
    public int nesting ( String S )
        int result = 1;

        if(S.contains(" "))
            S = S.replaceAll(" ","");

            S = S.replaceAll("\\(\\)", "");

        if(S.length() != 0)
            result = 0;

        return result;


Tips for sitting down for Codility test

  1. Only attempt test when you are completly free.
  2. Don’t type your code in Codility browser, decide which language you will be using and open your IDE before the test.
  3. IDE helps alot because you don’t have to remember whole API.
  4. Sit down for test where there is no distraction.
  5. Down try to solve the problem as soon as you get the question, think nicely and plan your algorithm on the paper first.
  6. Once you write your program,  test it will lots of invalid data. You can test your program on Codility browser.
  7. Practice sample test before sitting down for actual test.
  8. Don’t use nested for loops or nested branch statements in you solution(try to avoid them).
  9. RELAX.

My Final Thoughts

I prefer to be tested by humans rather than machines because i can explain to humans what i am thinking and how i am going to solve the problem. If i miss one comma in my program then human can understand it but if i miss one comma in program then machine can’t understand it and I may fail because of comma( if you are really scared of comma then learn Ruby language 🙂 ).

But on the positive side Codility can definitely save lots of time for employers  Company can not interview all the candidates who send them resume and I dont believe in resume because no one writes real thing on their resume. Every one says that they are punctual on their resume but on the very first day of their job they are late. In those cases Codilty can help employers to filter few candidates  for face to face interview. If i will ever own a software company then i may use software like Codility to help me with recruitment process or i may ask all my candidates to draw UML diagram for certain problem domain.

BTW i got 190/200 in my actual test.


14 thoughts on “Codility

  1. Hi!

    In your example, I think it’s easier to just pass through strings, count opening bracket as +1 and closing bracket as -1, make sure it does not get below zero at any iteration, and we get 0 at the end.

    This takes a blink of an eye to execute on 200K string (in Python):

    def check_parenthesis(value):
    i = 0
    for c in value:
    i += 1 if c == '(' else -1 if c == ')' else 0
    if i < 0:
    return False
    return (i == 0)

  2. Something similar but works even if there are other symbols, letters or numbers involved in string.
    Returns true or false

    Bulk logic is to turn string to array and remove everything not ( or ) from it
    then count ( as +1 and ) as -1 but if u ever go below 0 its not good ’cause there is more ) then ( so far
    in the end counter is either 0 – that is good or over 0 that is bad

    public static Boolean nesting ( String S ){
    int result = 1;
    char[] Sc = S.toCharArray();

    int count = 0;
    for (int its = 0; its<Sc.length; its++){
    if (Sc[its]=='(') count++;
    if (Sc[its]==')') count–;
    if (count0) return false;
    else return true;


  3. Interesting post, thanks for sharing. I did a test a few days ago and I failed with zero score out of 300! My mistakes: I thought a human would assess and mark my results. So, for the first task, my results were one position misaligned with the expected results (the result was a series of numbers which did succeed to produce, but got an extra value at position 0). As I thought a human would mark my code, I thought they would see that I have the main body of the algorithm correct and would probably discount a small penalty for a small mistake regarding indices lurking somewhere; so I submitted for that task. I then worked through the second task, and could only get it to about 50% completion when I realized only had 4 minutes left! At that point I thought, “well, I seem not to be able to complete this anyway” so I submitted that too and spent the remaining 3 minutes reading task 3. The surprise: task 3, despite having more paragraphs in its description was the easiest of them all! Anyway, after seeing the tasks and knowing I only had 90 minutes I knew I couldn’t produce impressive answers. But I would at least have properly debugged task 1 if I knew the scoring was based on correct results, and maybe I would have enough time to solve problem 3. Sorry, the comment got this long. I hope it could help somebody.

  4. The sample code you gave with odd being not properly tested is wrong. the brackets can be in odd numbers. like so ()(((()))) both “(” and “)” are 5 – which is odd yet they are properly nested.

    • Yes, but it will consider 5(odd) + 5(odd) = 10(Even). Hence the solution will work.
      But incase the test string contains third party characters other than `space`, then those also would have to be stripped to make this solution work.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s