Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The lesson here is use library functions. Someone smarter than you has probably optimized the hell out of them.


The glibc guys did not heed such advice :P


Indeed, in college I was interviewing for a job, and the interviewer asked how I would determine the length of a null terminated string, and I thought I nailed it by giving a typical "while(*(str++)) c++;" implementation.

The "right" answer was just to use strlen()...


I had a job interview once where the question was "find all descendants of a DOM node with a certain tag name, and return them in document order." I thought for about 30 seconds, and then wrote up on the board:

    element.getElementsByTagName(tagName);
That was what he was looking for. ;-) Of course, then he had me do it out as if getElementsByTagName didn't exist.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: