3 ms·
The actual question involved: > So basically it was a variation of the exact change problem (I realized afterwards). You had to validate a string of size n. 1
by kd5bjo 7y ago
The actual question involved:
> So basically it was a variation of the exact change problem (I realized afterwards). You had to validate a string of size n. 1 chunk of 8 characters could have 1 format, 1 chunk of 16 characters another, and 1 chunk of 24 characters another. You essentially had to determine if the string was valid. So in other words, find a combination of these sizes in which the string could be validated. I had 30 minutes
> It can be a string of size n. It needs to form a valid combo of 8, 16, and 24 char strings - each of which have an expected format. Result is T or F
This sounds like a pretty basic parsing problem to me, not dynamic programming, and likely to be a regular language. There’s a standard tool for this sort of thing, a “regular expression”. Not recognizing this much is a huge red flag for any kind of systems/integration role, like DevOps.
The answer here is just matching against this regex, with “fmt1”, “fmt2”, and “fmt3” replaced by regular expressions for the different packet formats:
^(fmt1|fmt2|fmt3)*$
- SubuSS 7y agoThe problem is that is bound by your regex implementation and how it handled overlaps the search strings :). Fwiw many places will just go the next step of - well implement the regex parsing then! But this is a dev perspective though. Am assuming a scripting answer might be good if the candidate knows about the actual regex behavior for devops.
- ummonk 7y agoI'm not sure they were going for the regex answer - it seems like they expected the DP answer since they're using multiples of 8, which allow you to do it as a DP problem quite easily.