Solved LeetCode program · 843 of 1,000
#1125 · Smallest Sufficient Team
Original English source
The requireds is a list of "java", "nodejs", and "reactjs". The skills is a list of "java", "nodejs", "nodejs", and "reactjs". The starts is a list of 0, 1, and 2. The counts is a list of 1, 1, and 2. The masks is a list of 3 zeros.
For every person from 0 to 2.
The mask is 0.
For every want from 0 to 2.
The required is item want of requireds. The bit is shift 1 left by want. The begin is item person of starts. The many is item person of counts. The finish is begin plus many minus 1.
For every entry from begin to finish.
The skill is item entry of skills. If skill matches required, set mask to bitwise or of mask and bit. Set item person of masks to mask.
The best is a list of 8 zeros. Set item 0 of best to 0.
For every state from 1 to 7.
Set item state of best to 1000000.
The chooser is a list of 8 zeros. The previous is a list of 8 zeros. The full is 7.
For every person from 0 to 2.
The gain is item person of masks. The state is full.
Repeat while state is at least 0.
The here is item state of best. The nextstate is bitwise or of state and gain. The candidate is here plus 1. If here is less than 1000000 and candidate is less than item nextstate of best, Set item nextstate of best to candidate, Set item nextstate of chooser to person, Set item nextstate of previous to state. Subtract 1 from state.
The answers is an empty list of whole numbers. The state is full.
Repeat while state is more than 0.
The person is item state of chooser. Place person into answers. The prior is item state of previous. Set state to prior.
The parts is an empty list of text. The spot is the last position of answers.
Repeat while spot is at least 0.
The person is item spot of answers. The piece is format whole number person as text. Place piece into parts. Subtract 1 from spot.
The line is join parts with ",". Show line.
Expected stdout
0,2