It's simple, unless you're given a specific broader context (like we have an enterprise customer data pruning system that needs to handle a broad range of corner cases) then you must not resort to overengineering this early in an interview.
"Return the lowest index in the string where substring sub is found within the slice s[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 if sub is not found."
Your instinct to resort to "in" is correc,t as it's generally slower than the "in" membership test, but the interviewer has even allowed the use of Google. Blanking out after that is really bad.
I don't understand how you jumped to the membership test instead of literally the .find() method on a string?
The interviewer is not asking to solve a problem here, they're asking for a simple ability to follow instructions, hence the offer to use Google to find the correct answer.
You could make a very solid case for using "in" (it is 2-4x faster), but only after you've solved the task at hand, this is what is expected in interviews. Not knowing the interview meta makes an average Joe basically unhireable in this market.
No worries. My point is, if you get asked questions that seem simple to the point where you feel they're asking if "water is wet", then you need to keep your own thinking process extremely simple in response.
The reason is the intent behind their question, which they don't vocalize.
This question means we are dealing with an extremely broad hiring funnel designed to fail people who can't FizzBuzz and need to keep answers at MVP level.
In other words, if you are asked to put out a fire use a bucket of sand, not a state-of-the-art fire extinguisher.
Step 2: Parse the output with your eyes. The method is literally called "find".
This one-trick pony failure mode could perhaps have been fine for a guy who did Java and nothing but Java for 10 years, but you are supposedly the person who runs "pythonforengineers" website...
What about 'in'? index()? There are at least 3 canonical methods for basic string searches, and 8 if your include the more specialized forms (all of which are considered solutions).
Please refrain from personal attacks here. Save that for less reputable forums.
You mean the same Anthropic, that wouldn't blink an eye at intentionally overcharging users hundreds of dollars just for having a HERMES.md file in a repo, would be above taking your data for... ethical reasons?
What's stopping you from making the trivial adjustment to the original question: "Who is the next likely person after Satoshi Nakamoto to have authored this"?
> Comma placement isn't really part of the language; it's part of the education system.
Interestingly, LLMs disagree with you.
Your statement is only accurate in an extremely narrow case, like if you were there to hear the person speaking, before their speech which was transcribed. Obviously, it is not true for almost all of human writing.
And if you were to go commaless, you will quickly get to rather precarious sentences, such as this one:
For Jevons paradox to be a win-win, you need these 3 statements to be true:
1)Workers get more productive thanks to AI.
2)Higher worker productivity translates into lower prices.
3)Most importantly, consumer demand needs to explode in reaction to lower prices. And we're finding out in real-time that the demand is inelastic.
Around 1900, 40% of American workers worked in agriculture. Today, it's < 2%.
Which is similar to what we see with coding: The increase in demand has not exploded enough to offset the job-killing of each farmer being able to produce more food.
reply