[ INFO ]category: Behavioral · Phone Screen difficulty: average freq: first seen: 2024-02-17
[AVERAGE][PHONE SCREEN]Phone ScreenSWE I (Entry Level)Unknown
$catproblem.md
Stripe - Phone Screen\n\n#### Part 1\n\n#### In an HTTP request, the Accept-Language header describes the list of languages that the requester would like content to be returned in. The header takes the form of a comma-separated list of language tags. For example:\n### \n#### Accept-Language: en-US, fr-CA, fr-FR\n### \n#### means that the reader would accept:\n### \n#### 1. English as spoken in the United States (most preferred)\n#### 2. French as spoken in Canada\n#### 3. French as spoken in France (least preferred)\n### \n#### We're writing a server that needs to return content in an acceptable language for the requester, and we want to make use of this header. Our server doesn't support every possible language that might be requested (yet!), but there is a set of languages that we do support. Write a function that receives two arguments: an Accept-Language header value as a string and a set of supported languages, and returns the list of language tags that will work for the request. The language tags should be returned in descending order of preference (the same order as they appeared in the header).\n### \n#### In addition to writing this function, you should use tests to demonstrate that it's correct, either via an existing testing system or one you create.\n### \n#### Examples:\n### \n#### parseacceptlanguage(\n#### "en-US, fr-CA, fr-FR", # the client's Accept-Language header, a string\n#### ["fr-FR", "en-US"] # the server's supported languages, a set of strings\n#### )\n#### returns: ["en-US", "fr-FR"]\n### \n#### parseacceptlanguage("fr-CA, fr-FR", ["en-US", "fr-FR\