USA: 2 weeks in, another 1 to go

In 2006 I decide that I wanted to leave my home country. I wanted to try hard and make some space for me in the world (well, the tech-world). I was really tired of being paid fuck all, dealing with a country driven by old-and-hard-to-die politicians, not seeing any foreseeable future in front of me. I made a decision, and I started working towards my leaving (I finishing uni, so this required a bit of planning). ...

January 31, 2012 · 4 min · 758 words

Find the non repeating char in O(n) time and O(1) space - v2

My colleague and friend Luca (@lucabox) described a better solution to the problem of "Finding the first non repearing char in a string in O(n) time and O(1) space". It uses smartly the space, making the solution nicer and slicker. Or we are just 2 geeks that need to give more attention to their girlfriends :P Luca’s solution description The logic of this solution is based on the usage of an array of unsigned chars. Every char (assumed to be lowecase) has an associated small byte (1 char = 8 bits), where the bits 0x1 and 0x2 (the 2 least significant) represents, respectively, “present once in the input string” and “present multiple times in the input string”. After the input is “scanned” once, and every letter is marked with the correspondent “presence bit” (once, multiple or none), it get’s scanned a second time to find the first char of the input which has the bit “present once” set to “1”. ...

December 18, 2009 · 3 min · 503 words