both problems here: https://leetcode.com/discuss/interview-question/5497148/snowflake-intern-oa-questions
Can anyone please give hints for the 2nd problem, I have no clue how to approach it. Thank you
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
both problems here: https://leetcode.com/discuss/interview-question/5497148/snowflake-intern-oa-questions
Can anyone please give hints for the 2nd problem, I have no clue how to approach it. Thank you
Name |
---|
Denote '0' for the zero-adjacent processor, '1' for the one-adjacent processor, and '2' for the two-adjacent processor. Then, each valid sequence of deployments results in a unique string of '0', '1', 'and '2'. We'll call such a string valid.
In a valid string, ignoring '1's, we see that '0' and '2' must "alternate", starting and ending with '0' (e.g. if you remove '1's in a valid string, then the sequence must look something like "020202020"). Furthermore, it is easy to see that any string that satisfies this corresponds to a valid sequence of deployments.
Then, setting up a DP recurrence should be relatively straightforward with this observation.
Think about applying all the possibilities of the types of adjacent and how for applying one type of operation on i, it affects on i+1.
It can be solved using dp
For example If want no adjacent on i, then it is bound for i+1 to be either one adjacent or two adjacent.
Or if I want i to be two adjacent then it bound for i+1 to be no adjacent or one adjacent
Thank you