An Interesting Problem On Arrays

Revision en1, by rachitiitr, 2018-02-09 12:37:45

Hi

Its been a while that I've made some video on competitive programming.

The problem that I want to talk about today is:

You are given an array A of size N < 1000 with elements upto 1018.
You have to print any subset S such that:
1. The AND resultant of all elements in S is 0.
2. The AND resultant of any 2 elements in S is not 0.

The problem looks easy but is quite twisted, and can be solved once you pick up the hidden observation here.
I read this problem sometime back in Petr's blog and wanted to share the solution with you guys.

Check out the video here: https://goo.gl/Pu9gZQ

Its difficult to pick up such observations but this is what I like about Competitive Programming. It makes you smarter gradually and you start looking at things in a different manner.

Happy Coding!

Tags rachitjain, video lectures

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English rachitiitr 2018-02-09 12:37:45 951 Initial revision (published)