Google Interview Preparation recommendations

So the last two posts I did about my Google Interview were well received – thank you so much for your kind comments.  

Today I’m sharing some of the things I did as part of the preparation: it’s clear to me that even if these made only a slight difference to how prepared I was for the interview (and actually it made a lot of difference) it  definitely made me a better coder.  My standard of work has raised since. This is probably only useful for people who are going to be taking serious programming interviews, sorry.

In terms of direct code writing,  I just started working through Project Euler.  I’m familiar with Project Euler from its appearance on the xkcd blog, but this was the first time I’ve sat down and tried to go though the problems. 

For those unfamiliar with the project, Project Euler is a set of (currently) nearly 500 maths/computer science problems that require a certain amount of both mathematics and also algorithmic knowledge to solve. They start relatively easy and start getting substantial at around number 50 or so.  For context – the first problem has been solved by a little over 377,000 people and the 90th by just over 5,000 people. 

Working on the Project Euler problems really did bring back the joy of coding: I wasn’t fighting an interface or googling an obscure error message, or trying to set up the right upgrades and dependencies just to get the program installed.  Instead I was reasoning abstractly, on interesting problems and using a language I knew well to deploy algorithms I’d designed.  It was really quite wonderful. 

Roughly once a week Project Euler releases a new, deeply difficult, problem. Three times I found the time to block out the Sunday day or Saturday night and look into a problem.  It was wonderful – I absolutely just lost myself into the code for hours and hours at a time.  

I was in the first 100 people in the world to solve this problem: http://projecteuler.net/problem=463 and there are still only about 300 people who have.  It was nice to know that I could operate at that level.  

I was also reading. A lot.  

Some of the reading was things that it was embarrassing that I hadn’t read before. 

Design Patterns.

Design patterns : elements of reusable object-oriented software is one of those books that I’d seen sitting on people’s shelves for years and never bothered with because I didn’t design big systems or even work on big systems.  I generally worked on single-author academic systems for years at a time and was happy that I didn’t have to go though that big historical book.   

When I actually sat down and read it I realised how wrong I was.  It’s not that I imagine I’ll be using any of the 23 classic patterns any time soon, or even that I expect to in any way change my code. It’s that this book pretty much defined the language we use to name things in various APIs and languages and repositories. 

 Imagine that you had spent years hearing jokes about elephants, without ever having seen one or even knowing that they were jokes. Then you read the Wikipedia page and watch a video and every 30 seconds you think ‘Ahhh…That’s what that guy was going on about’.   I find that I’m much happier not only looking though APIs but also reading other people’s code. Github has gone from being completely incomprehensible to being largely confusing. It’s absolutely a book that you don’t realise you needed. 

Clean Code
Uncle Bob’s Clean Code: A Handbook of Agile Software Craftsmanship is an easy read on a page-by-page basis.  It’s all well reasoned advice (changing my own position on a couple of things). When it’s not changing your mind about things it comes over as the code equivalent of a diet and exercise book – full of things that you know you should be doing. I read this book quite slowly because every hour I had to stop and refactor something significant in my code.  

Effective Java and Java Puzzlers
The only two Java-specific books I’m recommending are both wonderful.  Java Puzzlers: Traps, Pitfalls, and Corner Cases is the perfect book for reminding you how little you know about a language. Every section is a small snippet of code and the question ‘what does this do?’.  Invariably you answer wrong and spend the next few pages being educated.  I can only imagine it’s an excellent book for interviewers or people who just enjoy knowing one extra fact.  

Effective Java (2nd Edition): A Programming Language Guide is a bit more straight laced and item based, but it manages the difficult task of being both for people who have been programming for years and still being accessible to academics like me.  My major thing with Effective Java is that I think it’s a book you read once and leave on the shelf.  Then when you are having a tricky problem you scan down the list of items and say ‘ah, I think that item is the one I want’ and then go and read it up – I think it’s a book of hooks rather than something more manifesto-based like Clean Code. 

Algorithm Design Manual
The one that was probably the most *actual* help in the interview, certainly in terms of knowing direct facts, rather than simply writing better code, was the The Algorithm Design Manual.  It’s a big thick book that one reads cover-to-cover and reminds you of algorithms you had forgotten and things that you never considered useful but now do. It was a great help for the Project Euler Problems I was working though (I finally got the hang of Dynamic Programming). Again I think it’s a nice book of ‘hooks’ to have on your shelf and say ‘I think I’ve seen this in the Algorithm Handbook’. 

I read many many others – these were the ones that I got tangible value out of.  

I was called.

Note for the reader: I wrote this post a little while ago just before I started on the Google interview process. It’s a very traditional thing that anyone who goes though the process talks about it and I wanted to do two posts – one with my feelings before the interview and one with my feelings after. Today is the before, and I’ve avoided editing it since (with the unfortunate result that it’s actually quite badly written) to preserve the of-the-time feeling.

 

‘Cause I was thinkin’, it really don’t matter if I lose this fight. It really don’t matter if this guy opens my head, either. ‘Cause all I wanna do is go the distance. Nobody’s ever gone the distance with Creed, and if I can go that distance, you see, and that bell rings and I’m still standin’, I’m gonna know for the first time in my life, see, that I weren’t just another bum from the neighborhood.

Rocky, 1976

 

Photo from: http://www.edudemic.com/ways-use-google-tools-maximize-learning/

Photo from: http://www.edudemic.com/ways-use-google-tools-maximize-learning/

I was called to interview for Google.

I have, honestly no idea if I’m close to good enough. I am, with no false modesty, pretty good. But I have no idea if I’m that good. I do know that I’m at least good enough to know just how far ahead of the curve the guys that make it really are.

The call is validating, someone picked though the CVs and pulled out mine as being the sort of CV that might fit.  That’s pretty nice, I’m proud of that. But I could have just made nice formatting choices. 🙂

The prize, the real prize is at the end of a long process, and every stage of the process that I make it though (and I expect to make it through only a very small distance) is a massive amount of validation: 90% of applications that reach the first technical interview are washed out.  The people who reach the final stage, the full day of back-to-back interviews, only a third of them make it.

I intend to make it as far as I can, and if/when I fail, I intend to have no excuses. So let’s eliminate some of them right now.

Google’s interviews are data-driven, if you make it to the last stage then the people who make the decision look at the reports of those who interviewed you, the questions you were asked, and they make the decision based on that.  Since they started they’ve been saving data on interview questions so they can genuinely compare the performance of people who’ve been there for five years with how they did on each type of interview question. If an interview question/question type is not a good predictor of how someone performs at their job, then this is passed to the interview trainers and so such ‘unhelpful’ questions are removed from the setup (Google famously stopped asking trick or hypothetical questions for this reason several years ago).

So if I don’t make it, then it’s not because the interview questions were ‘stupid’ or because the interviewer ‘didn’t like me’. There is a data-driven process designed to work and work well. It’s not going to be because ‘there was a more impressive candidate’ or because I didn’t know the right people. There’s a standard, I have to reach that standard.

It’s not going to be because I’m unprepared.  I’ve spent the last four weeks working very hard indeed….   I’m in the algorithmic shape of my life.

I’ve not suffered any major emotional upheavals.  I have a day job to do, and do well, but I can rearrange almost all my other activities and commitments until after the process.

The only possible reason I have for failing this process is by not being good enough to pass it. I also know that the only way I can find out if I am of the right standard or not is by working as hard as possible to pass.

 

 

 

Minimalist Wallets

Tl;dr – I’m going to complain about minimalist wallets for a couple of paragraphs and then show you mine.

 

I get mildly annoyed with minimalism for superiority. It’s easy to spot,  generally if you have to buy something to show how minimalist you are, then you’ve missed a point somewhere. If you are still confused then I highly recommend working your way down Erin Doland’s list of unitaskers, which is entertaining at any time.

My particular irritation today was will minimalist wallets. Wallets designed not to hold very much. But oddly, enough, that cost a lot of money (leaving you less to put in the wallet presumably, and thus being a bit of a self-fulfilling prophecy). I keep seeing page after page of ’20 minimalist wallets that X’

It’s not the price that irritates, its the utter specialization:

  • ‘Slots for three cards’ – not two, and definitely not four, but three.
  • ‘holds X bills’ – which is great as long as you don’t live in, or ever intend to visit, well any other country with different shaped money.
  • and my very favorite….

Screen Shot 2014-03-10 at 20.00.05…space for exactly three pound coins.  Given I don’t think that a 50p piece could fit in there I’m not sure how change is supposed to work (I don’t think coins normally go in a wallet, but what do I know?).

Sigh.

So what’s my alternative you ask? Well I don’t care about fashion really so I bought a half dozen of these from eBay

Screen Shot 2014-03-10 at 20.17.18…and attached them with a handy key ring.

It’s great. Cards go in them, so does folded money.  I can always easily find my Oyster card, or my bank card. I can hang them up next to my keys at night. If I find that they don’t hold enough cards then I go and get another slot from the cupboard and the problem is solved.  (Also, for those who pay attention to such things, no animals were harmed in the making of this wallet).

IMG_1668

Minimal, you want minimal? For comparison, my old fairly minimal wallet, centre, and the wallet of the first housemate to walk into the room when I was taking a photo.

 

Screen Shot 2014-03-10 at 19.58.08I just wanted to point out that maybe if you are trying to reduce the amount of stuff you have, you should think about all you really need. And to also rail a little bit of the idea that minimalism is having the same amount of stuff, just in a really specialized tiny space that becomes useless as soon as circumstances change. I don’t think being minimalist is achieved by just putting everything in a very particular place. I think its achieved by getting rid of it.

Getting rid of spare change

Like most people I have a box of spare change that is inconvenient (or embarrassing) to go out and spend.

IMG_1505

This is a common enough practice that there are machines in UK supermarkets that will sort your loose change for you and print a voucher for the supermarket, which is nice and convenient except that that they take 8.9% commission (you could, of course, go to the bank, but the whole point of such machines is that people are in supermarkets a lot more than they are in banks, and apparently the difference is enough to make the commision worthwhile).

 

IMG_1503

What’s interesting, is that also in the supermarket (in the UK at least) there are these the self service checkouts, and they have an inviting hole for coins.

IMG_1484

…and they work just like the larger coin sorters. (Eagle eyed viewers will note that this photo was taken at a different supermarket than the one above – largely because they don’t have one of the big sorting machines at my tiny local supermarket)

So when I have a box of change to get rid of – I go in at a quiet time (this is important, because you would hold the queue up otherwise), I do my weekly shop and I empty my jingling pockets a bit at a time into the hopper. Some coins are rejected (an astonishing proportion turn out to be US currency) but the bill rachets down and anything remaining is paid on a credit card.  I just think this is an elegant way to clear out your change and ease your budget a little, while avoiding the 8.9% overhead.

Bookmarklet to make Gmail return more than 20 search results.

Gmail’s “sort not search” philospohy changed the way many of us use email, but limit of 20 results per page is irritating to many.  Here’s how you can fix the limit with a bookmarklet.

When I search for ‘from:ted’ in my inbox, the url that my browser shows is this one:

https://mail.google.com/mail/u/0/#search/from%3Ated

And it shows these emails:

Screen Shot 2014-02-08 at 10.42.14

 

There’s space for more emails, so why can’t I see them? Irritating, huh?

We’re not alone.  Googling ‘Gmail more than 20 results’ gets you a lot of angry users who are mostly now complaining that they’ve complained about this since 2009 and Gmail hasn’t helped.

Here’s my solution (I found the technical part of this on this stackexchange question).

If, I change the url to:

https://mail.google.com/mail/u/0/#section_query/from%3Ated

Then I get to see all 33 (not 28 that the previous page claimed) of the emails:

Screen Shot 2014-02-08 at 10.42.05

This is a nice easy little hack to show up to 100 threads in the search results. If you have more than 100 threads, then the normal ‘<‘ and ‘>’ buttons work well.

It’s a bit of a pain to keep changing the url, so I wrote a little bookmarklet to do the job (using the Bookmarklet Crunchinator).

To start using the bookmarket, make sure you can see your browser’s bookmarks toolbar. Then, drag and drop the bookmarklet link below to your bookmarks toolbar. When you’re on a page where you want to use the bookmarklet just click its name on your toolbar. (or, if you are like me and hide the toolbar, just click it in the bookmarks menu.

BetterGmailSearch

EDIT –
Some people on Lifehacker (which picked up the article) found that they were getting 50 messages in the search results, rather than 100). It turns out that this method won’t return more search results than fit in your inbox.  For example, I have this setting in my gmail settings.

Screen Shot 2014-04-05 at 09.06.15This means that (normally) I get to see up to a 100 messages in my inbox, but still only 20 in my search pane. When I use the URL hack in this article, I get to see 100 emails in my search pane.

On the other hand – if I set that setting to ’50’, then I would normally see up to 50 messages in my inbox and 20 in the search pane – but the URL hack will let me see 50 in the search pane.

 

SECOND EDIT –

For those illustrated, this is a wonderful example of the drawbacks of StackExchange’s voting method. On the relevant question, the answer that says “No, there’s still no way to do that.” has 10 early votes putting it as the top answer, while the (two) answers that show easy ways of doing it, both languish at the bottom with two votes each (presumably from each other).

THIRD EDIT:

(with thanks to the person who emailed in)

This doesn’t work if you used gmail’s advanced search, which looks like this:

Screen Shot 2014-04-18 at 08.39.36because advanced search, for some reason, doesn’t use the same url structure.  The workaround is as follows:

  • Perform the advanced search – giving a maximum of 20 results
  • Press the normal ‘magnifying glass’ search button – this will use the settings in the search box (generated from the advanced search) to perform a the same search
  • because you used a ‘normal’ search last – the URL should now contain ‘search’ as normal, and the bookmarklet should work 🙂

How to sleep on the floor comfortably

I took this photo myself one morning.

I took this photo myself one morning.

People interested in this article might like to read about the sleeping contest, or maybe even why I threw away my alarm clock

One of the most useful skills I acquired in my 20s was the ability to sleep on the floor. Sleeping on the floor makes staying over after parties easier, make visiting friends more comfortable, and meant that layovers and four hour delays in airports pass with much less stress.

(I should say that as I’ve moved further away from my 20s these things have become less useful: parties have got more civilised and friends have bought bigger houses. But it’s still a useful skill to have).

The problem

The problem was that it was hard(both the process and the floor). Every four months or so I’d decide that tonight was the night to become someone who sleeps on the floor. I’d take my blanket, lay down and I’d suddenly be aware that I’d never been so awake in my life. Half an hour later I’d have given up and be back in bed.

The solution

Years later, I finally worked it out. At the time, my alarm was going off in the morning at about 7am. So I set it for 5am, with the rule that I didn’t have to get up when it went off, I just had to roll, complete with duvet and pillows, off the mattress and on to the floor.

Logically, one of two things can happen at this point, either you find yourself thinking I’ve never been so awake in my life, in which case you’ve solved the problem of how to get up early in the morning. Congratulations!

More likely, because you are still tired, warm, comfortable, and relaxed you’ll go back to sleep. You are now sleeping on the floor.  Congratulations!  This is what happened to me.

The next night I set my alarm another two hours earlier, to 3am. Once again I roll out of bed, and go straight back to sleep. I kept at 3am for two nights, before going to 1am.

The reason this works is because you are taking advantage of this:

comic image about sleeping

(Image from http://cheezburger.com/2535989760, extremely difficult to trace original owner.)

Once you are at 1am, you are spending most of the night sleeping on the floor; you’ve got comfortable, and you’ve lost the mental block you had. So by the end of the week I was comfortably lying down on the floor and drifting off with no problem. It’s an approach I highly recommend.

I’ve also used the same method to switch to sleeping on my left side and sleeping on my back, when I had problems with the right side of my neck, and I suspect it works for a range of other things.

 

Recommended Viewing: Randy Pausch

So this is a productivity post – normal service to be resumed shortly…

Portrait of Randy Pausch from wikicommons

Randy Pausch was a Professor in Computer Science at Carnegie Mellon University. He did a great many wonderful things – one of which that he regularly gave a time management talk to students. He was given a terminal diagnosis of Cancer in 2007, and died in 2008. He reprised the Time Management talk at the university of Virginia in late 2007 and it’s very much worth viewing.  I’ve recommended this video to every student I’ve taught since I first watched it, primarily for its content – it’s full of excellent practical advice – but also because when a man in that position tells you about time management, you listen.

(As ever, page image from wikicommons)

 

 

(Randy has a more famous aspirational video as well, which I also think is good – but I find myself coming back to this one again and again and again)

Throw away your alarm clock.

Stock photo of the sun rising

(I was going to use a stock photo of an alarm clock from wikicommons, but I’ll take any excuse to show a sunrise)

Early rising has bothered me a lot over the last few years, and I’ve really wanted to get the hang of it. I see a lot of people who change the world for the better are early risers (there’s a nice article on that subject at the Guardian) and it’s, certainly within UK culture synonymous with getting the best out of life… (“You’ll have to get up very early in the morning to get the better of me”).

I tried various approaches, some of which worked better than others (including a year of a sleeping contest with an anonymous stranger) and felt like I got the hang of a fairly solid regime. I was getting up when my alarm went off. I was pretty solid.

At this point, I found myself on StackExchange, giving my opinion about something. In response to a question on ‘how sleep debt decays’ I wrote the following:

Very little research exists and [over a long period of time it may not even be possible…][1], the model I work under is this. If you sleep less than your body would like to, then you pay for it, either you pay for it in terms of more sleep the next day, or you pay for it in terms of lost alertness, creativity, or mood. Here’s the thing – if we were cattle, and all we had to do was eat and stand, then sleep deprivation wouldn’t make that much difference to everyday life – similarly if the thing we have to do in a day is travel, then being sleep deprived might not make a difference when all you are doing is sitting on a plane seat for 15 hours. But if you work in a creative, intellectual, or life-or-death trade, then being 10% off your best can have serious long-term implications (junior doctors working on very little sleep are the classic case). I suspect that the trade-off isn’t this simple but consider it as a question – you can wake up an hour early every day of your life, but you’ll be only 95% percent of the person you could be – would you take that choice? [1]: http://www.usatoday.com/news/health/2007-11-25-sleep-deficit_N.htm

After I wrote that, I thought about it. Then I thought about it some more. Maybe I had a point.  I could imagine that I really was forcing myself out of bed an hour early than I should have been, and I strenuously objected to the idea of being 95% of the person I could be.

So during 2013 I tried an experiment: No alarm clocks. If I had a meeting and I didn’t get up in time, then I missed the meeting (the exception being if I had to be on a train/plane by 7am, in which case the special ‘oh god it’s still night time’ alarm was fine – this was necessary no more than a dozen times over the year). If it turned out I already was getting the right amount of sleep then there would be no difference, and if I found myself blinking at noon then that was probably a sign I should have done this sooner right?

For the first month there was a bit more sleeping, but not by that much (I should say that I didn’t miss any meetings due to oversleep in the year) and waking up naturally was very much prefered to waking up with blaring noise…

After that something very strange happened. I started waking up, fully refreshed earlier and earlier… getting up a good hour before I would have done with the alarm clock (I have a fairly solid 11pm bedtime generally), and more to the point, opening my eyes and being *awake*, no messing about with snoozing. I have no explanation – people have suggested silly things like sleep cycles, vitamins, daylight, and fear of it being noon – but it was very welcome for all that it was counter intuitive.

It’s not all good news – this early alarmless waking worked fine until about September but then, perhaps triggered by later and later dawn, I started waking later and later and later. Until I was getting up maybe an hour after my normal alarm time. But the point is that I think I was needing that sleep – I wasn’t getting any less work done, or leaving things unreplied to (feel free to check the stress graph for this), and I certainly wasn’t having any less fun, or missing out on time with friends (there is a slew of birthdays and parties and wedding anniversaries around that time and I find that Autumn/Winter is starting to take the brunt of my social calendar…)  I can only presume that the extra sleep was helping, and that I really was more refreshed, got thought work faster, and was more lively the rest of the time.  It may be that I was sleeping more (it’s receded a little bit now) *because* I was so busy.

This has been something of a leap of faith for me. It’s been something I’ve doubted, and I don’t know for sure if it really did help. But I’m glad I did it.

Richard Wiseman changed how I get angry.

I’m going to recommend a book before I’ve finished it. That’s confidence.

Rip it up is the second book I’ve read by Richard Wiseman (I highly recommend 59 seconds anyway) and I have been blown away by the explanation given of how the body recognises anger in itself. To oversimplify vastly there is a sense in which part of your brain goes ‘I notice I’ve got an elevated heart rate and I’m warmer than normal, but my breathing is fine. I’m probably in the grip of some strong emotion, what’s going on? Oh, that pedestrian just walked into me – I’m probably angry about that. Grrr’

(There is also a sense that the opposite is happening – if I could explain it well then I would write a post rather than just telling you to get the book)

It has had a genuine effect on me. More than once since reading it I’ve felt like I was angry, but then when I stop to examine the feeling in this context, it lifts completely and I suddenly realise it was actually excitement or one of half a dosen other things.  The explenation in the first half of the book is excellent and does a good job of going over the experiments that were conducted to get to the bottom of this.

Read it, go on.  At least the first half.  Much of the rest of the book is largely saying ‘The scientific evidence is showing that you should fake it until you make it”

Not remembering…

When you’re more mature, you do start telling the truth, in odd situations. “I’m sorry, I’ve broken a glass here. Is that expensive? I’ll pay for it. I’m sorry.” And you do that so that people in the room might go, “What a strong personality that person has. I like to have sex with people with strong personalities.”

Eddie Izzard, Dressed to Kill.

I’ve had to spend a lot of time (outside of work) in the last few months dealing with a person who, to put it politely, quite often says things that are  inconsistent with many other things that they have previously said. This has got me thinking a lot about lying.

Continue reading

I shouldn’t tell you this but…

picture from wikipedia

(There isn’t really a sensible picture to go with this post, so here is a beautiful one from wikicommon’s featured images – link is this one

One of the most useful habits I’ve got into in the last few years is this.

When someone starts a sentence with “I shouldn’t tell you this, but-“, I stop them.

That’s pretty much the whole of it, but it’s such a useful little thing, I suddenly found I had fewer inconvenient secrets clattering around in my brain.

It turns out, when I look back over the times that people shouldn’t have told me X, that X has pretty much never been useful to me. It’s never made me happier, healthier, or richer. All it’s done, is that it’s meant that there is a least one person in the world who when I meet, I have to remember a fact, and then remember that I’m not to mention the fact and after going though that process I can then actually start thinking thoughts that are, you know, useful.  Really when someone is saying ‘I shouldn’t tell you this, but -” they are saying ‘I’m going to make life harder for you, while at the same time showing that I am fully aware that I am a poor friend’.

So yes, if I had to pick one habit that’s made my life better over the last few years it’s that one. If you want information, go to Wikipedia.

EDIT – two edits I need to make here, first of which is to clarify – this only happens about three times a year (I looks kind of ‘high school’ on first reading) and secondly it was pointed out to me that I only do this for social or personal matters – I’m all ears for industry gossip – I’ll have to change that…

 

 

 

 

Keeping track of time…

People who follow me on Twitter will be used to seeing messages of the general form:

and people who I work with are used to seeing my desktop with the time-spent diagnostic at the bottom…

Screen Shot 2013-12-02 at 20.08.05

…and I’m semi-regularly asked a) who cares? (which is not the subject of this post) and b) how do I track this?

Let’s talk about how I track it…

Continue reading

Book recommendation: Tricks of the mind

One year after I wrote this post,  I updated it significantly here.

Trick of the mind is getting on for six years old now, and despite it’s somewhat disconnected themes, I’d like to recommend it on the strenght of the memory section alone. It really is an excellent introduction to the power, and the methods, of using one’s memory properly.

Mr Brown spends some time on the major method of remembering numbers and, mildly unhelpfully doesn’t use the ‘standard’ set of translations. A little while ago I wrote a python script to translate numbers to words using the Derren Brown encoding and I thought I’d put it on the internet in case anyone else would like a go.

Numbers to letters using Derren Brown’s encoding.

The amazon link is below – feel free to follow 🙂