Perguntas de entrevista para o cargo de software development engineer compartilhadas pelos candidatos
He asked the best way to store boolean values on memory. I said an array but he wanted more, so in the end I said BinaryVector class. He asked why a binary vector is a better option but I couldn't answer that. I told him that I don't know the internal implementation.
After that I was thinking about this and I think I have the answer but couldn't imagine that under pressure. I'll not put here because I'm not sure.
You should user a Integer to store flags. You can storre up to k flags (or booleans) with a k bits processor. That is Usualy made in C like THIS FLAG0 = 1 FLAG1 = 2 FLAG2 = 4 ... FLAGN = 2^n You can set 2 flags like this setted_flags = FLAGx | FLAGX2 and see if its setted wifh setted_flags & FLAGx