|
Unspun posted:Use a pointer at each end of the string and move them towards each other. Stacks? Arrays?! Christ! gently caress!! if this is your reaction in an interview then the interview has served its purpose
|
# ? Jun 18, 2019 04:23 |
|
|
# ? May 17, 2024 15:06 |
|
that's gonna give you the wrong answer because you'll see "()()", match the leftmost and rightmost character, and then conclude that the parentheses don't match because ")(" doesn't match
|
# ? Jun 18, 2019 04:27 |
|
Also, again, that is probably an incorrect solution (but it depends on what the precise question is). EDIT: right, what JEB! said ^^^^
|
# ? Jun 18, 2019 04:28 |
|
It's a context free language. Emulate a pushdown automaton and move on with your life.
|
# ? Jun 18, 2019 04:28 |
|
Jabor posted:if this is your reaction in an interview This is the Coding Horrors thread of something awful dot com, apologies for any confusion
|
# ? Jun 18, 2019 04:30 |
|
Unspun posted:This is the Coding Horrors thread of something awful dot com, apologies for any confusion fair enough, I guess it is the appropriate place to be absolutely certain of yourself while also being totally wrong
|
# ? Jun 18, 2019 04:31 |
|
Jabor posted:fair enough, I guess it is the appropriate place to be absolutely certain of yourself while also being totally wrong No, that place is called "production".
|
# ? Jun 18, 2019 05:08 |
|
rjmccall posted:(a)b{c} My wife pointed this out too when I tried the problem with her. Came here to relay the message but someone's beaten me to it. Spoke too soon earlier when I was so impressed by it. Oops. Not looking forward to myself getting tripped up on special cases like that soon in interview problems. One thing I hate is how many of them are expressed purely as puzzles. Here's a problem of searching through m bags of n permutations of o strings of...... who cares. It reminds me of none of the situations I normally face as a programmer and does not put me in my best thinking mood*. I don't solve puzzles, I solve problems. Put one of those in front of me and phrase it as an engineering need and I'll get it. *Another thing that does not put me in my best thinking mood: Having someone look over my shoulder or expecting a conversation while I'm trying to think through a problem. I don't want to just draw a blank because I'm picturing what the interviewer's expectant face looks like right that moment, or worse, looking at it in person. They wouldn't force me to do that on the job, so I don't see why it's a good test to try it during an interview. Different kinds of pressure that people work well under, etc. Can I hang up the phone with them while I'm thinking it over? Because that is obviously what I would do in real life, on the job. I'd never just trust my solution that I found to something in real time mid-conversation. Happy Thread fucked around with this message at 08:44 on Jun 18, 2019 |
# ? Jun 18, 2019 08:32 |
|
"...well, I would simply google "FizzBuzz optimal solution" and copy/paste whatever has the most upvotes". "You're hired".
|
# ? Jun 18, 2019 08:47 |
|
If all the problems you needed to solve on the job were small enough to work out in a 1-hour interview, you wouldn't get paid very much. Everyone is aware that the toy problems used for interviews aren't completely representative of what the job actually involves - the point is more about your general ability to solve problems with code than it is about your ability to identify the solution to this particular artificial problem. So no, just not saying anything to the interviewer and then coming back twenty minutes later with a canned solution is not a good way of showing off your problem solving skills, let alone the communication skills you'll also need to be successful in a programming job.
|
# ? Jun 18, 2019 08:47 |
|
I have such an interview tomorrow, so I had a go in JS. Shred me.code:
code:
|
# ? Jun 18, 2019 09:38 |
|
The first question I would have when presented with the problem is, what's a "bracket" here? because I'm sure Unicode has lots of funny characters that are brackets. and the original statement just says it's "a string", it doesn't say "an ascii string" or w/e.
|
# ? Jun 18, 2019 10:45 |
|
Hammerite posted:The first question I would have when presented with the problem is, what's a "bracket" here? because I'm sure Unicode has lots of funny characters that are brackets. and the original statement just says it's "a string", it doesn't say "an ascii string" or w/e. Hmm. Good point. So first up we’re going to need a BracketProviderFactory interface,
|
# ? Jun 18, 2019 10:54 |
|
Soricidus posted:Hmm. Good point. So first up we’re going to need a BracketProviderFactory interface, Don’t forget the CorrespondingBracketComparerFactoryService.
|
# ? Jun 18, 2019 11:28 |
|
Guys, guys this can all be achieved with regex if you use lookaheads. It's a regular language unlike html!
|
# ? Jun 18, 2019 11:51 |
|
rjmccall posted:(a)b{c} Not in test cases, therefore not my problem. In honesty 90% of a technical interview is seeing how you solve/iterate on problems. So add test case and fix.
|
# ? Jun 18, 2019 12:19 |
|
Nolgthorn posted:Strip everything except brackets from the string, if it's an odd length fail, then match half the indexes against the opposite using a switch statement. I like it. code:
|
# ? Jun 18, 2019 12:44 |
|
Trammel posted:I like it. immediately marched out the door for asking me to read perl
|
# ? Jun 18, 2019 13:01 |
|
I'm sorry I cannot read your code because I am not a terminator.
|
# ? Jun 18, 2019 13:12 |
|
leper khan posted:Don’t forget the CorrespondingBracketComparerFactoryService. 1. First, we need to create a settings registrar. The idea behind the settings registrar is that we want to conceive of the languages used to determine what the brackets are as a simple POCO so we can inject it into the service layer later, but we also want to solve configuration settings in general. It's really annoying just to be able to configure settings in a webconfig key, so the idea behind the settings registrar is from the developer's perspective, they just inject the poco, whereas we can use the magic of dependency injection to create a hierarchy of settings. The settings registrar will flatten the pocos into key value pairs (as all forms of data persistence, in essence, boil down to key value pairs) - this allows us to pull settings hierarchically from a web config / mongo / even an oracle database using a minimum of effort, and the developer need not know where the settings actually came from. 2. In order for the settings registrar to resolve this particular poco, we need to create a ILanguageReader - this will act as the class for reading brackets specified for a language. We next need an ILanguageResolver - the resolver will use reflection to turn the key value pairs into the original poco specified. 3. Finally, we have a set of pocos indicating what brackets go with which language. What we can do is consider every language an IBracketPreprocessor - the base bracket preprocessor obviously should be EnglishBracketPreprocessor, but we can register the additional languages returned by the pocos as decorators for the original preprocessor. Using the magic of generics, we can declare a BracketPreprocessor<T> that can be instantiated from the injected settings pocos (we obviously need the base class to be a real preprocesor, but the additional preprocessors will take the previously applied preprocessed brackets as the argument in the constructor, following the decorator pattern.
|
# ? Jun 18, 2019 13:56 |
|
Dumb Lowtax posted:
As an interviewer I generally care more about your thought process than the actual answer given, especially the first pass. Don't hang up, start naive and acknowledge that you may/will have a clean up pass. If you hang up and then come back with an answer you might just have come to this thread for help which isn't the point of the exercise.
|
# ? Jun 18, 2019 13:58 |
|
eh... https://stackoverflow.com/questions/52969755/how-to-check-the-sequence-of-opening-and-closing-brackets-in-string
|
# ? Jun 18, 2019 14:16 |
|
ma galaxybrainJavaScript code:
|
# ? Jun 18, 2019 15:05 |
|
Nolgthorn posted:Not in test cases, therefore not my problem. An excellent answer for the coveted “junior engineer with no hope of advancement and yet still has a chip on their shoulder” position.
|
# ? Jun 18, 2019 15:29 |
|
bad code here
xtal fucked around with this message at 15:59 on Jun 18, 2019 |
# ? Jun 18, 2019 15:34 |
|
Given a string, make sure every "Fizz" is matched with a "Buzz"
|
# ? Jun 18, 2019 15:46 |
|
Yep, after the last page or so, I am now 100% in the impostor syndrome camp again.
|
# ? Jun 18, 2019 15:47 |
|
To be fair, I'm not exactly sure what among my experiences led me to think "stack!" so quickly, so
|
# ? Jun 18, 2019 15:54 |
ratbert90 posted:Yep, after the last page or so, I am now 100% in the impostor syndrome camp again. Don't be. You can be a great programmer and still be bad at or intimidated by the typical interview questions. Just because some people are very good at interview questions doesn't make them a better or more competent programmer than you.
|
|
# ? Jun 18, 2019 16:00 |
|
ratbert90 posted:Yep, after the last page or so, I am now 100% in the impostor syndrome camp again. I know a developer who, after spending 3+ years working purely in C#, would still copypaste StackOverflow answers written in java - without realizing it was a different language - and then lose an entire day of work trying to figure out why the compiler kept bitching about the @SomeAttribute poo poo in his code, despite it CLEARLY working in the answer. So if you're able to read a given piece of contextless code and realize whether or not it's even written in your use-case language. You're already doing better than *some* people who make a living developing software.
|
# ? Jun 18, 2019 16:39 |
CPColin posted:To be fair, I'm not exactly sure what among my experiences led me to think "stack!" so quickly, so It's probably because stacks are a good guess for a lot of interview-style questions. My typical thought process is roughly
IME you can get pretty far just based on that + explaining your thought process as you go + some experience with these sorts of questions + being lucky enough not to be someone who freezes up during interviews.
|
|
# ? Jun 18, 2019 17:02 |
|
The real takeaway from all this is that if enough of these bloody top-tier tech companies need brackets parsed so desperately there's a decent usecase for a domain-specific language. So just write one of those and then smugly produce the source code in your interview.
|
# ? Jun 18, 2019 17:24 |
|
NtotheTC posted:The real takeaway from all this is that if enough of these bloody top-tier tech companies need brackets parsed so desperately there's a decent usecase for a domain-specific language. So just write one of those and then smugly produce the source code in your interview. Unfortunately that didn't work for the Homebrew guy
|
# ? Jun 18, 2019 17:26 |
|
Ola posted:I have such an interview tomorrow, so I had a go in JS. Shred me. Just use !t jeez
|
# ? Jun 18, 2019 17:29 |
|
code:
|
# ? Jun 18, 2019 18:20 |
|
CPColin posted:To be fair, I'm not exactly sure what among my experiences led me to think "stack!" so quickly, so Probably because when discussing language theory, "balanced brackets" is the example that every single professor and textbook likes to roll out first when talking about nonregular languages, almost always with a note that you need at least a pushdown automaton for them. The "balanced brackets" -> "stack" association is ubiquitous.
|
# ? Jun 18, 2019 19:37 |
|
Cuntpunch posted:I know a developer who, after spending 3+ years working purely in C#, would still copypaste StackOverflow answers written in java - without realizing it was a different language - and then lose an entire day of work trying to figure out why the compiler kept bitching about the @SomeAttribute poo poo in his code, despite it CLEARLY working in the answer. I worked with a guy who was convinced he improved Javascript with a horrendous utils directory. He obfuscated everything you could do in Javascript, if statements, filter, map everything, to the point where no code anywhere was anything more than function calls within function calls all the way down. He was absolutely certain that it was superior to vanilla Javascript and wouldn't listen to a drat soul who told him to stop doing it. He worked at the company for like a year driving everyone insane. Nolgthorn fucked around with this message at 21:36 on Jun 18, 2019 |
# ? Jun 18, 2019 21:34 |
|
VikingofRock posted:Don't be. You can be a great programmer and still be bad at or intimidated by the typical interview questions. Just because some people are very good at interview questions doesn't make them a better or more competent programmer than you. My specialty is embedded Linux systems engineering. I am more used to poking registers and doing some python or C++ stuff as well. Simple things like bracket parsing is apparently too advanced for my broke brain. Nolgthorn posted:I worked with a guy who was convinced he improved Javascript with a horrendous utils directory. He obfuscated everything you could do in Javascript, if statements, filter, map everything, to the point where no code anywhere was anything more than function calls within function calls all the way down. So Jquery?
|
# ? Jun 18, 2019 23:01 |
|
Yeah isn’t that just normal npm
|
# ? Jun 18, 2019 23:04 |
|
|
# ? May 17, 2024 15:06 |
|
Nolgthorn posted:I worked with a guy who was convinced he improved Javascript with a horrendous utils directory. He obfuscated everything you could do in Javascript, if statements, filter, map everything, to the point where no code anywhere was anything more than function calls within function calls all the way down. Oh hey, let's trade dreadful JavaScript "utility functions". I'll go first: JavaScript code:
|
# ? Jun 18, 2019 23:17 |