hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

9.4K
active users

Šimon Tóth

Tuesday common C++ interview problem: Locked doors.

Given an array of n locked rooms, each room containing 0..n distinct keys, determine whether you can visit each room.

You are given the key to room zero, and each room can only be opened with the corresponding key. Assume that you can freely move between rooms.

Solve it yourself: compiler-explorer.com/z/zx85hG
Solution: compiler-explorer.com/z/bY9q9x