Kurumo ([info]angrauko) wrote,
@ 2008-12-17 14:47:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
Current location:At work

Observations on interviewing:

- over 3/4 of all candidates with C/C++ on the resume cannot reverse a linked list in those languages (in place)
- over 1/3 cannot do it in principle, in any language or by any method, with multiple tries
- over 1/2 have no concept of how to reverse digits in a number without converting the said number to a string
- the above holds regardless of the degree; if anything, Masters in Computer Science do worse on average. (I regard MS as a red flag at this point).
- candidates who declare Java as their preferred programming language in general have a weaker grasp of algorithms and little to no idea of architecture

:(




(Read 11 comments) - (Post a new comment)


[info]vombatus
2008-12-17 09:52 pm UTC (link)
Поскольку сам не образованный и не програмирую, решил попробовать. Без гугла, но возился долго. На тройку тянет?
class Node:
        def __init__(self, data, next=None):
                self.data = data
                self.next = next

        def add(self, node):
                if self.next:
                        self.next.add(node)
                else:
                        self.next = node

def reverse_list(node):
        if node: a = Node(node.data)
        if node.next: b = Node(node.next.data)
        while node:
                node = node.next
                b.add(a)
                a = b   
                if node:
                        if node.next: b = Node(node.next.data)
        return a

def reverse_int(x):
        p1 = 1
        while x / p1 >= 10:
                p1 = p1 * 10
        y = 0
        p2 = 1
        while x > 0:
                digit = x / p1
                y = y + digit * p2
                p2 = p2 * 10
                x = x - digit * p1
                p1 = p1 / 10
        return y

(Reply to this) (Thread)


[info]angrauko
2008-12-18 07:07 am UTC (link)
Мне кажется с листом неправильно, но на тройку тянет :)
В любом случае, Python я не знаю, но надо полагать для целых чисел это выглядело бы где-то так -
def reverse_int(x)
   result = 0
   while x:
      digit = x % 10
      result = result * 10 + digit
      x = x // 10
   return result

(Тоже ничего interview problem - here is a language you don't know, write some code in it :)

(Reply to this) (Parent)


(Read 11 comments) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…