top of page

Daily Code Challenge #4

There are N couples sitting in a row of length 2 * N. They are currently ordered randomly, but would like to rearrange themselves so that each couple's partners can sit side by side.


What is the minimum number of swaps necessary for this to happen?

You can attempt at this challenge here.


Bonus Challenge

What does the below code snippet print out? How can we fix the anonymous functions to behave as we'd expect?

functions = []
for i in range(10):
    functions.append(lambda : i)

for f in functions:
    print(f())
 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating

Subscribe to get exclusive updates

Thanks for subscribing!

CONTACT ME
avatar-formal-round.png

Follow

  • Medium
  • Facebook
  • Twitter
  • LinkedIn
  • Instagram
  • Youtube
  • linktree
  • Buy Me A Coffee

© 2019 - 2024 By Biyi Akinpelu. The LORD Is My Banner

bottom of page