What's IAC ?Also a bit surprised that people here are not familiar with IAC, is that because this a nerd forum where everyone wants to work on videogamez or something?
What's IAC ?Also a bit surprised that people here are not familiar with IAC, is that because this a nerd forum where everyone wants to work on videogamez or something?
Okay, guys, check this out. I'm not sure if it's a coincidence but:
1. You flip the keys and values.
2. You sort all the keys. (so it's in order)
3. You check if there no duplicate keys and/or are out of bounds.
Now the freaky part:
4. You check if any of the keys have the same value as the original array.
If not, it should be a circular loop.
It's not a coincidence and sorting is costly.
Sorting part can be skipped, as long as you follow the keys.It's not a coincidence and sorting is costly.
It's also 3 passes through the array AND a sort. It can be done with a single pass through the array (untested code posted no previous page)
Ah nvm this post, I think it will reduce performance.Yes, it's easy. I think it's a weeding-out question.
Think about it: You have to go through the array at least once, even if you're doing magic like, I don't know, assemble a number from the values and check whether it meets some mathematical criterium that fits.
Exception handling aside, as soon as you're doing more than that, your chances getting hired are drastically lowered.
After that, they ask you to paint a petri net of torrent networking in action from the perspective of a tracker or something.
I don't see how it's a riddle. It says "Here's a problem, please write a function to produce correct output given the problem requirements".
A riddle is asking, for example, if you place 1 ant on each of the 3 vertices of an equilateral triangle, and they all simultaneously choose one of their two adjacent edges to walk along until they reach the next vertex, what is the probability that no two ants will collide.
Now that the thread has mentioned the processes for hiring managers and stuff, I want to ask, what are the possible career paths for a developer? I don't want to get stuck making web pages forever, but also I don't want to stop coding, or at least doing technical stuff, I would hate to end up in manager positions, but is all my coworkers (and everyone I know) seem to be aiming for, what are your thoughts?
Now that the thread has mentioned the processes for hiring managers and stuff, I want to ask, what are the possible career paths for a developer? I don't want to get stuck making web pages forever, but also I don't want to stop coding, or at least doing technical stuff, I would hate to end up in manager positions, but is all my coworkers (and everyone I know) seem to be aiming for, what are your thoughts?
Now that the thread has mentioned the processes for hiring managers and stuff, I want to ask, what are the possible career paths for a developer? I don't want to get stuck making web pages forever, but also I don't want to stop coding, or at least doing technical stuff, I would hate to end up in manager positions, but is all my coworkers (and everyone I know) seem to be aiming for, what are your thoughts?
Reading through the last couple of pages, and specifically Soneet's confusion on strings being arrays has enlightened me a bit to part of the problem I think that is going on. A lot of modern languages treat strings as objects, and developers could very well not have had any exposure to how a string works on a lower level. I imagine a lot of CS courses will touch on these things, but not everyone has a CS background, and I think you'd be foolish to only hire CS grads. I myself have a CS degree, and could tell you how to reverse a string in something like C or Java, but couldn't tell you how a string is being stored in Ruby, which is a language I've used on a daily basis for the last 4 years.
While I still don't think asking someone to reverse an array is a great interview question, it might at least be a bit clearer.
EDIT:
To be clear, if you are hiring for a position that is going to be more low level, and require that someone understands how a string is stored, then yes, you should ask those kinds of questions. If you are trying to hire a web developer using anything modern, then you are either kidding yourself on how low level you need to get on a day to day basis, or you are totally over-engineering.
All I got from that whole episode was a (stubborn?) inability to see the proper abstraction, or to separate the commonality of the algorithm from the usage of the result, as that's just noise. It came across as somewhat Mort-ish.
I use Ruby pretty frequently and I'm not sure how reversing a string in Ruby is really any different from reversing it in any other language.Reading through the last couple of pages, and specifically Soneet's confusion on strings being arrays has enlightened me a bit to part of the problem I think that is going on. A lot of modern languages treat strings as objects, and developers could very well not have had any exposure to how a string works on a lower level. I imagine a lot of CS courses will touch on these things, but not everyone has a CS background, and I think you'd be foolish to only hire CS grads. I myself have a CS degree, and could tell you how to reverse a string in something like C or Java, but couldn't tell you how a string is being stored in Ruby, which is a language I've used on a daily basis for the last 4 years.
While I still don't think asking someone to reverse an array is a great interview question, it might at least be a bit clearer.
EDIT:
To be clear, if you are hiring for a position that is going to be more low level, and require that someone understands how a string is stored, then yes, you should ask those kinds of questions. If you are trying to hire a web developer using anything modern, then you are either kidding yourself on how low level you need to get on a day to day basis, or you are totally over-engineering.
def reverse str
reversed_str = ""
str.chars.each do |ch|
reversed_str = ch + reversed_str
end
reversed_str
end
If you really never have the need to iterate through an array and do anything out of sequence, you're probably not doing "modern" development of any sort.Using the roles in that article, for a lot of modern languages, someone like 'Elvis' might not even know how a string is being stored in the language. As we move forward, and classes are taught with these languages, 'reversing a string' becomes the same as 'bit-twiddling'.
I use Ruby pretty frequently and I'm not sure how reversing a string in Ruby is really any different from reversing it in any other language.
Everything has an Object wrapper in Ruby. And to be honest, I don't care how Ruby stores strings internally (except regarding how it handles different character sets). Ruby's a horribly inefficient language and nobody using it is doing so because the underlying implementation is amazing. Unless I'm streaming exceptionally large amounts of data the implementation of String is the last thing on my mind. But the core concept here--that reversing a string and reversing an array are the same--has absolutely nothing to do with how strings are stored internally or your choice of language.Nono, he talked about how strings are stored in Ruby.
It's a sequence of bytes with an Object wrapper and appropriate methods, if you care to know.
I use Ruby pretty frequently and I'm not sure how reversing a string in Ruby is really any different from reversing it in any other language.
You could also do it with a reduce or use indices or do it a myriad of other ways, but the basic premise is the same. It's not something where choice of language should trip you up. Like at all.
If you really never have the need to iterate through an array and do anything out of sequence, you're probably not doing "modern" development of any sort.
It's very efficient! It's efficient in terms of actual programming. You get shit done in Ruby real fast. And the library landscape is great, which gives a lot of extra efficiency.Ruby's a horribly inefficient language
Re: your spoiler, you can always do str[index..index]. Which is dumb but works.Yes, reversing an array is going to be the same, no matter your language.
Asking someone to reverse a string is going to require that they understand a string is stored as an array. If you've never had to treat a string as an array, and I don't really see why you would in a modern language, it's sort of bunk to expect that someone is going to know that.
Completely off-topic, and unrelated, but you actually wouldn't be able to reverse it with indicies straight up in Ruby 1.8.7, due to the fact that the [] method on strings returns the char byte code, ie 'abc'[0] returns 97.
Re: the first part, that's total bullshit. You don't need to understand how a string is stored internally to recognize that it's an array, you just have to think for two seconds about what reversing a string really means--reversing its characters.
I don't think you and I are speaking the same language. Forget programming for a moment.How do I know a string has characters?
I don't think you and I are speaking the same language. Forget programming for a moment.
I ask you to reverse a string. What does that mean to you? To me, it means "reverse its letters." There. We're done. I now know I have to be able to isolate the string's letters and reverse them. So a string in this context has to be thought of as a list of letters. An ordered list. An array. Okay, we're reversing an array. Nowhere did we need to even touch a computer to figure this out, and yet you're trying to convince me that you need to know the "underlying implementation" for this to make sense. Even if your interviewee doesn't actually know the function to extract the characters, that's fine as long as he can coherently explain where to go from there.
But that leap is probably the most interesting part of the question. If a person really cannot wrap his or her mind around the idea that a string is made up of letters--if, effectively, a person can't even understand the request "reverse this string"--then do you really want him or her working on your project?In your train of thought you are making the connection that you can somehow represent a string as it's letters. I don't think that's a crazy connection to make by any means, but I think that if you've never had to make that connection before, if you've never had to treat a string as anything more than just a string, that it also wouldn't be crazy for someone to not realize that they could somehow deconstruct the string down to the characters that make it up.
I'm not even saying the person has to know how to GET the letters, they might not even know that they CAN.
But that leap is probably the most interesting part of the question. If a person really cannot wrap his or her mind around the idea that a string is made up of letters--if, effectively, a person can't even understand the request "reverse this string"--then do you really want him or her working on your project?
Well, I do always complain about it and how I learn close to nothing for my tuition, so that might be it. However, because of this you could say I would fail OP's interview miserably. But I'd argue that I would probably be a one of the better (or the best, which is what I always aim for) programmer if they hired me. My 1st post in this thread, I mentioned that the term 'talent' shouldn't be misunderstood. Questions like in the OP doesn't scout talent.
Software architect.
As you move up the technical career ladder, you basically start distancing yourself away from low level code.
I'd agree. I do the systems and architecture work at my job, but I'd feel out of the loop if I wasn't doing low level code as well. So I tend to design the overall system and subsystem interfaces and then lay the groundwork for others by doing the hardest parts of the lower level stuff. It also helps in presenting example code, style, conventions, etc.There are no dedicated software architects where I work. Intermediate and senior developers are the major contributors to the overall design of a feature, but everybody on the technical side is involved in the implementation.
I don't think I'd have it any other way, either. Even if a person who wasn't involved in the details of the implementation could do an equally good job at designing the system, he'd have to clearly communicate more information to a lot more people than if the responsibility were just distributed more widely. Even if the overall design of a project is huge, you can almost certainly modularise it and apply a similar strategy.
First of all... what? Manipulating strings is a fucking huge amount of programming (yes, even modern programming, since for you apparently anything that happened five or more years ago is ancient history). Any network transactions are probably going to involve tons of parsing, as does validation on both the server and client side. I'm really sort of baffled that you'd even say something like this. If someone's applying to your job and isn't that familiar with manipulating strings, they might well be brilliant but you're still going to have to spend a fair amount of time ramping them up--so you'd at least want to make sure they understand the core concepts. Which leads to the next point...It's not a leap in understanding the problem any better, though, it's having known something beforehand or not, through having had a need to mutate or manipulate a string in some way. I think it'd be pretty uncommon to not have had a need to do that, but I don't think it's totally out there either.
Last time I respond to this. It has nothing to do with having had to mutate or manipulate a string before. In order to even define reversing a string you have to understand that the string is made up of letters. You are getting so hung up on this point about what you've been exposed to and what the computer's doing internally that I almost think we're not talking about the same thing.I wouldn't use the question in an interview, because of the above, and because I don't think it's an interesting question. I said this earlier, but if I wanted to know if I wanted them to work on my project or not, I'd have them work on my project with me for a few hours, which is how I interview people for the company I work at right now.
Here is what I think is a good algorithm to test for complete circular arrays:
1. Starting at index 0, iterate through the array using the given method (next index is the element at the current index). Keep track of the number of iterations.
2. For each iteration do the following in order:
>a. Check that the next index is within the array's bounds. If not, it's not a circular array.
>b. If the next index is 0, and the number of iterations is not equal to the size of the array, then it is not a complete circular array.
>c. If the number of iterations is the same size as the array, and the next element is 0, then the array IS a complete circular array.
>d. Check that the next index is not the same as the current index. If it is, it's not a complete circular array.
Basically, it checks if you hit every element if you try to traverse through it. If it's a complete circular array, you MUST end up at the element you started at after going through exactly n elements (n being the size of the array), and NEVER before that point.
It runs in Otime (it's simply a traversal through the array), and uses O(1) space. There might be an optimization I'm missing but this should cover all cases fairly well, unless I'm really misunderstanding something.
There are no dedicated software architects where I work. Intermediate and senior developers are the major contributors to the overall design of a feature, but everybody on the technical side is involved in the implementation.
I don't think I'd have it any other way, either. Even if a person who wasn't involved in the details of the implementation could do an equally good job at designing the system, he'd have to clearly communicate more information to a lot more people than if the responsibility were just distributed more widely. Even if the overall design of a project is huge, you can almost certainly modularise it and apply a similar strategy.