Technical interviews - prep

Soldato
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
So I narrowly missed the cut on the technical test I just took (14/20 required I scored 13). I am dead serious about wanting to move in the new year, so I want to be as prepared as I possibly can be.

So what are must knows for technical tests, what areas should I be reviewing? I am a Java developer, being in a small company means I do a bit of both backend and frontend.

The product I work on is client server based GUI using jnlp to download the client jars from a Tomcat webapp.

Ideally I'd like to move in to web frameworks using Spring MVC and similar, but this isn't something I use in work so I have to go on my experience with personal projects.

So far my experience tells me interviews don't tend to be specific to any frameworks/API's and focus on core language. My Java language knowledge is I think pretty good, but I suppose I am lacking in some more core computer science areas such as (I do have 2:1 comp-sci degree but it's been a while)

- Algorithms, what should I know. It's been 10 years or more since I've done things like binary search, quick sort, bubble sort etc.
- Data structures. My day to day use I use the standard ArrayList, HashSet, HashMap that's about it (our code is littered with Vectors too which I'm not overly pleased about, but refactoring these would be a big task). Things like LinkedList, TreeMap, Queue etc. I rarely use but I will occasionally look them up to remind myself
- Time complexity, I never 'got' Big-O notation when I was doing my comp-sci degree. I have looked up easier to read explanations (Wikipedia's mathematical expressions went right over my head) of it recently and I get it a bit better, but I'm not hugely confident I could look at an algorithm and say "Oh that's O(1), O(n), O(logn), O(nlogn), O(n^2) etc."
- Design patterns, I know a handful and I know the categories, there's only a few I could write without having to lookup. I'm not sure how important these are in the context of a technical interview (I'm sure interviewers would cringe if I mentioned Singleton :p).
- Are there certain logic puzzles I should be well practiced at?

I can hear some people thinking "He's a programmer, mathematical knowledge is key", but the truth is the majority of what I code is "boilerplate" code, communicating data between code layers etc.

Umm yeah, so advice please! Perhaps this could prove useful to others in a similar position.
 
Soldato
OP
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
Thanks for that I'd love to avoid recruiters, I'm more than happy to phone companies up and say 'giz us a job'. It's how I got in to the company I'm in now. But I'm not entirely sure how to find companies in the surrounding area who are either software company's or have departments
 
Soldato
OP
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
How about a bit of advice about dealing with agents? Decided what with only a few weeks left of the year I'd start properly looking on some of the sites, and sent my CV to a couple I saw on CW jobs.

Now I'm being hounded.
 
Soldato
OP
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
What are peoples opinions on submitting code after an interview, i.e. what you would've coded if you'd had more time to consider it?

Had an interview today and I was asked to implement a StringBuffer

I did this, I realise the toString is a bit...... well crap

Code:
package com.testing;

import java.util.ArrayList;
import java.util.List;

public class StringBuffer1 {

  private List<Character> characterBuffer;

  public StringBuffer1() {
    characterBuffer = new ArrayList<Character>();
  }

  public void append(String anotherString) {
    if(anotherString != null) {
      char[] charArray = anotherString.toCharArray();
      for(int i=0;i<charArray.length; i++) {
        characterBuffer.add(charArray[i]);
      }
    }
  }

  public String toString() {
    return characterBuffer.toString().replace("[", "").replace("]", "").replace(",", "").replace(" ", "");
  }

}

He asked me if there was a way I could improve the toString method, I blanked, 10 minutes on the way home in the car. I thought of this solution. DOH!

Code:
package com.testing;

import java.util.ArrayList;
import java.util.List;

public class StringBuffer2 {

  private List<Character> characterBuffer;

  public StringBuffer2() {
    characterBuffer = new ArrayList<Character>();
  }

  public void append(String anotherString) {
    if(anotherString != null) {
      char[] charArray = anotherString.toCharArray();
      for(int i=0;i<charArray.length; i++) {
        characterBuffer.add(charArray[i]);
      }
    }
  }

  public String toString() {
    char[] charArray = new char[characterBuffer.size()];
    for(int i=0; i<charArray.length; i++) {
      charArray[i] = characterBuffer.get(i);
    }
    return new String(charArray);
  }

}

He also asked for alternatives and I did discuss the possibility of using a primitive char array instead as a buffer, and the buffer grows if there is an overflow.

If I'd have thought of it first I would've implemented this

Code:
package com.testing;

import java.util.Arrays;

public class StringBuffer3 {

  private char[] characterBuffer;
  private int curIndex;

  public StringBuffer3() {
    characterBuffer = new char[5];
    curIndex = 0;
  }

  public void append(String anotherString) {
    if(anotherString != null) {
      char[] charArray = anotherString.toCharArray();
      int charArrayLength = charArray.length;
      if(overflow(charArrayLength)) {
        characterBuffer = Arrays.copyOf(characterBuffer, newLength(charArrayLength));
      } 
      for(int i=0;i<charArray.length; i++) {
        characterBuffer[curIndex++] = charArray[i];
      }
    }
  }
  
  private int newLength(int arrayLength) {
    return (characterBuffer.length + arrayLength) + 10;
  }
  
  private boolean overflow(int arrayLength) {
    return (arrayLength + curIndex) > characterBuffer.length;
  }

  public String toString() {
    return new String(characterBuffer, 0, curIndex);
  }

}

I realise the interview is done now, but it's really bugging me that I didn't pick up on what he was talking about improving my toString. I'm hoping that the fact that I discussed the possibility of option 3 will count in my favour!

So find a way of submitting the ideal solution? Or don't bother

It was a timed test. Which apparently I'm not very good at
 
Soldato
OP
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
Didn't get that one :(

I do however have a couple of second interviews in the new year :)

Also I submitted my CV to IMDB and I was sent a link to a codility test which I have to complete by tomorrow. So I've spent the past couple of days preparing for it. Click on the link for the test tonight and......

500: system error

The team has been notified about the issue and will act on it shortly.

Argh!!!

Edit ok sorted and submitted. Codility is an interesting way of testing, thankfully the questions I was given weren't as tricky as some of the questions they ask
 
Last edited:
Soldato
OP
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
And I passed that test! Cool! :D

Telephone interview with some peeps in Seattle in the new year!

Looks like another technical interview, using some collaborative edit tool. Sounds scary!
 
Last edited:
Soldato
OP
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
So on Friday I have another interview, the technical side of things there is a test. Direct quote from recruitment agent

There will be a refactoring test involved in the interview process. Be prepared for this, it will involve IDEs & Eclipse. The format will be talking through what you’d change in the code and why, so quite a practical exercise. You may also be tested on some basic Java questions, perhaps in areas you haven’t put any thought to for some time, so I suggest you read up on some basics of ‘textbook’ Java.

Doesn't sound too hard :confused:

I'll just assume that means making code more modular and perhaps separating some stuff out in to different classes etc.
 
Soldato
OP
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
Just going through some of the questions from "Cracking the coding interview". One of them says

Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures?

Not entirely sure what she means by additional data structures? If I could use additional data structure I'd use a set, but since I can't I did it this way

Within the requirements? She uses some sort of bit vector in her solution

Code:
  public boolean hasAllUniqueCharacters(String s) {
    char[] chars = s.toCharArray();
    Arrays.sort(chars);
    char current = '\u0000';
    for(int i=0; i < chars.length; i++) {
      if(current != chars[i]) {
        current = chars[i];
      } else {
        return false;
      }
    }
    return true;
  }
 
Soldato
OP
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
Sorry humour me a minute whilst I try to understand

get bit

Code:
boolean getBit(int num, int bit) {
  return ((num & ( 1 << bit)) !=0);
}

Is this for checking if a bit is set? So for example

Code:
num = 4
bit = 2
            0100&
0001 << 2 = 0100
            ----
            0100

num = 8
bit = 2
            1000&
0001 << 2 = 0100
            ----
            0000

Seems to work for those, but 8?

Code:
num = 8
bit = 4
             1000&
0001 << 4 = 10000
            -----
            00000

Shouldn't bit 4 be set?
 
Soldato
OP
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
You have an off by 1 error, 0010 has the second bit set. 0100 has the 3rd but set == 4. The decimal 4 does not have the 2nd bit set.

Yes but the result of 1<<4=16 doesn't it? So 8 & 16 = 01000 & 10000 = 00000

The question itself doesn't mention any assumptions, the answer does however
 
Last edited:
Back
Top Bottom