Skip to content

Instantly share code, notes, and snippets.

@alesker
Last active September 27, 2021 12:27
Show Gist options
  • Save alesker/2b46c75fdf0e78fec6298bed91266f38 to your computer and use it in GitHub Desktop.
Save alesker/2b46c75fdf0e78fec6298bed91266f38 to your computer and use it in GitHub Desktop.
// simpleFeature
/*
Let's say we have an app that works by fetching data from network and allows storing that data for offline use.
Implement a simple feature that fetches, stores and presents a list of contacts and with an ability to select a single contact and view its details.
APIs:
struct Contact {
let id: String
let name: String
let email: String
}
let contacts: [Contact] = PipedriveNetworkClient.get(path: "my_contacts")
...
PipedriveContactsStorage.save(contacts)
...
let savedContacts = PipedriveContactsStorage.fetch()
*/
// tallestSkyscraper
/*
A city skyline can be represented as a 2-D array with 1s representing buildings. In the example below, the height of the tallest building is *4* (second-most right column).
[
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0],
[0, 0, 1, 0, 1, 0],
[0, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 1]
]
Create a function that takes a *skyline* (2-D array of 0’s and 1’s) and returns the height of the tallest skyscraper.
tallestSkyscraper([
[0, 0, 0, 0],
[0, 1, 0, 0],
[0, 1, 1, 0],
[1, 1, 1, 1]
]) ➞ 3
tallestSkyscraper([
[0, 1, 0, 0],
[0, 1, 0, 0],
[0, 1, 1, 0],
[1, 1, 1, 1]
]) ➞ 4
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment