Using a language of your choice, implement a function to deduplicate a list of words, so that, the function receives the list as an argument and returns the list without the duplicates. Here's an example in Javascript
const wordList = ['not', 'a', 'pheasant', 'plucker', 'but', 'a', 'pheasant', "plucker's", 'son']
console.log(deduplicate(wordList))
[ 'not', 'a', 'pheasant', 'plucker', 'but', 'plucker\'s', 'son' ]
NB: the order of the output list does not matter.
There are many ways to do this - feel free to google your options. We want to see:
- The function in syntactically correct (and readable) code.
- An explanation of why you would choose this particular method.
- A unit test!
Imagine you are implementing a booking system for a peer2peer car share.
User A, "Lender" needs to specify when their car is available, while user B, "Borrower" needs to be able to reserve the car at their preferred time. A car can only be lent to one person at a time.
What data schema would you need to store in order to support these use cases? Feel free to demonstrate a solution in your favourite datastore. The solution should support a simple query to show what cars are available at a given time (even if some bookings have already been made). You don't have to do it relational schema, but you have to show how the query would look.
Here's an example in psuedocode to get you started:
+----------+
| car |
+----------+
| id |
| user_id |
| metadata |
+----------+
+----------+
| user |
+----------+
| id |
| metadata |
+----------+
Relations:
car belongs to user
There are many ways to do this - feel free to google your options. We want to see:
- Some kind of schema (e.g. sqldump, JSON)
- Example of how the query would look
- Why is this solution better than some alternative?
You have a frontend app written in ReactJS and you are preparing it for production. The app needs to call an API server with a FQDN configured in the variable API_BASE_URL. There will be a production deployment and a staging deployment for demos/testing. How would you deploy the frontend so that the same build (minified JS, CSS and HTML) can be used in production and staging deployments?
We want to see:
- A description of how your implementtion would work, e.g. a docker file or a deployment config
- A list of steps you need to take to change the FQDN of the API (API_BASE_URL) for production or staging
- How would you handle new versions of the API?
Please submit your solution as a PR including some nice commits for challenge 1 and the rest in Markdown.