← Questions

Mutual top choices on apartment-swap wishlists

0
StripeCodingLast asked Sep 2021

On an apartment-swap site each user ranks other users' apartments in a wishlist, rank 0 being the favourite.

  1. Given a user and a rank, say whether the match is mutual: the user at that rank also ranks this user at the same rank.
  2. If the user moved the entry at a given rank up by one place (swapping it with the one above), which users' mutual status with them would change? Answer without modifying the stored wishlists and return the names sorted.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding