I like how the sample question on Triplebyte tests API memorization instead of algorithms knowledge. Of course, you can't win. At a whiteboarding session, there will always be applicants who give out the method from the library instead of providing an algorithmic solution.
I found it to be an ok question; not at all an API one. The answers differ quite a bit, and by choosing one and explaining why you can show that you understand what you’re doing. For example, if you choose str.indexOf(‘ ‘) you clearly have no idea what you’re doing, and if you pick str.count(‘ ‘) - 1 you look like you saw the actual solution somewhere and are picking something that looks similar without really thinki…
In particular, https://doc.rust-lang.org/1.0.0/unicode/str/trait.UnicodeStr... is an ancient counter-example (it was replaced by split_whitespace).