Problem Statement
John and Brus have become very famous people all over the world, especially in Bolivia. A man in Bolivia decided to write a story about them. To make the story more truthful, he set up an interview with John. He prepared a list of distinct simple "Yes" or "No" questions and he enlisted the help of two friends to transcribe the interview. Each time he asked a question, one friend wrote down the question while the other friend wrote down the answer. He was very nervous when conducting the interview, so he might have asked some of the questions multiple times. However, John's answers always remained the same for the same questions.
Unfortunately, the friend who was writing down the questions lost his list.
In a desperate attempt to remember the order in which he asked the questions, the Bolivian has decided to write down all the possible ways that he might have asked them.
He knows for sure that he asked every question from his list at least once.
You are given an
Definition
- Class:
- TheQuestionsAndAnswersDivOne
- Method:
- find
- Parameters:
- int, String[]
- Returns:
- int
- Method signature:
- int find(int questions, String[] answers)
- (be sure your method is public)
Constraints
- questions will be between 2 and 9, inclusive.
- answers will contain between questions and 9 elements, inclusive.
- Each element of answers will be either "Yes" or "No".
Examples
2
{"No", "Yes"}
Returns: 2
The two possible ways are: the first question followed by the second question, or vice versa.
2
{"No", "No", "No"}
Returns: 6
3
{"Yes", "No", "No", "Yes"}
Returns: 12
3
{"Yes", "Yes", "Yes", "No"}
Returns: 18
6
{"No", "Yes", "Yes", "Yes", "Yes", "No", "No", "Yes"}
Returns: 40320
6
{"Yes", "No", "No", "Yes", "No", "Yes"}
Returns: 720
4
{"Yes", "No", "Yes", "No", "Yes", "Yes", "Yes", "No"}
Returns: 1704
5
{"No", "Yes", "No", "No", "No", "No", "Yes"}
Returns: 4200
5
{"No", "No", "No", "Yes", "No", "No", "Yes"}
Returns: 4200
6
{"Yes", "Yes", "Yes", "No", "No", "Yes", "No", "No", "No"}
Returns: 169920
5
{"No", "Yes", "Yes", "Yes", "No", "No", "No", "No", "Yes"}
Returns: 33120
8
{"No", "No", "No", "No", "Yes", "No", "Yes", "No", "Yes"}
Returns: 725760
5
{"Yes", "No", "No", "No", "No", "No"}
Returns: 1200
5
{"No", "Yes", "Yes", "No", "No"}
Returns: 120
6
{"No", "No", "No", "No", "No", "Yes", "No"}
Returns: 10800
6
{"No", "Yes", "No", "Yes", "No", "No", "Yes", "No", "No"}
Returns: 216000
5
{"No", "No", "Yes", "No", "Yes", "No", "No"}
Returns: 4200
6
{"Yes", "No", "No", "No", "No", "No", "No", "No"}
Returns: 100800
5
{"No", "No", "Yes", "No", "No", "Yes", "No", "Yes", "No"}
Returns: 43920
9
{"No", "Yes", "Yes", "No", "Yes", "No", "Yes", "No", "Yes"}
Returns: 362880
3
{"Yes", "Yes", "No", "Yes", "Yes"}
Returns: 42
2
{"Yes", "Yes", "No", "No", "Yes"}
Returns: 2
3
{"Yes", "Yes", "No", "No", "Yes", "Yes", "Yes", "No", "Yes"}
Returns: 204
2
{"Yes", "Yes", "No", "Yes", "No", "Yes", "Yes"}
Returns: 2
2
{"Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes"}
Returns: 126
5
{"Yes", "Yes", "No", "Yes", "Yes", "No", "Yes"}
Returns: 4200
4
{"Yes", "Yes", "Yes", "Yes", "No"}
Returns: 144
2
{"Yes", "No", "Yes", "Yes", "Yes"}
Returns: 2
2
{"Yes", "No", "Yes", "Yes", "Yes"}
Returns: 2
5
{"Yes", "Yes", "No", "Yes", "Yes", "Yes"}
Returns: 1200
8
{"No", "Yes", "No", "No", "No", "No", "Yes", "Yes", "No"}
Returns: 725760
9
{"Yes", "Yes", "Yes", "No", "Yes", "Yes", "No", "No", "No"}
Returns: 362880
8
{"No", "Yes", "No", "Yes", "No", "Yes", "No", "No", "Yes"}
Returns: 645120
7
{"Yes", "No", "No", "Yes", "Yes", "No", "No", "No", "Yes"}
Returns: 463680
7
{"Yes", "Yes", "Yes", "No", "Yes", "Yes", "No", "Yes", "No"}
Returns: 559440
9
{"No", "Yes", "Yes", "No", "Yes", "No", "No", "Yes", "Yes"}
Returns: 362880
7
{"No", "No", "No", "Yes", "No", "No", "Yes", "Yes", "Yes"}
Returns: 463680
9
{"Yes", "Yes", "No", "Yes", "Yes", "Yes", "Yes", "Yes", "No"}
Returns: 362880
7
{"No", "No", "Yes", "Yes", "Yes", "No", "No", "Yes", "No"}
Returns: 463680
7
{"No", "No", "Yes", "No", "No", "No", "No", "Yes", "No"}
Returns: 811440
8
{"Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes"}
Returns: 40320
7
{"Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes"}
Returns: 2328480
7
{"Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes"}
Returns: 141120
9
{"No", "No", "No", "No", "No", "No", "No", "No", "No"}
Returns: 362880
9
{"No", "Yes", "No", "No", "No", "No", "Yes", "Yes", "No"}
Returns: 362880
2
{"No", "Yes", "No", "No", "No", "No", "Yes", "Yes", "No"}
Returns: 2
8
{"No", "Yes", "No", "No", "No", "No", "Yes", "Yes", "No"}
Returns: 725760
9
{"Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes" }
Returns: 362880
9
{"No", "No", "No", "No", "No", "No", "No", "No", "No" }
Returns: 362880
8
{"No", "No", "No", "No", "No", "No", "No", "No", "No" }
Returns: 1451520
7
{"Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes" }
Returns: 2328480
9
{"No", "Yes", "Yes", "No", "Yes", "No", "Yes", "No", "No" }
Returns: 362880
6
{"Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes" }
Returns: 1905120
7
{"No", "No", "No", "No", "No", "No", "No", "No", "No" }
Returns: 2328480
2
{"Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "No" }
Returns: 2
8
{"Yes", "Yes", "Yes", "Yes", "No", "No", "No", "No", "No" }
Returns: 645120
7
{"Yes", "Yes", "Yes", "Yes", "No", "No", "Yes", "No", "No" }
Returns: 463680
2
{"Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes" }
Returns: 510
8
{"Yes", "Yes", "Yes", "Yes", "Yes", "No", "No", "No", "No" }
Returns: 645120
5
{"Yes", "No", "No", "Yes", "Yes", "No", "No", "Yes", "Yes" }
Returns: 33120
7
{"Yes", "No", "No", "No", "Yes", "No", "No", "Yes", "Yes" }
Returns: 463680
9
{"Yes", "No", "Yes", "No", "Yes", "Yes", "Yes", "No", "No" }
Returns: 362880
6
{"Yes", "Yes", "No", "Yes", "No", "Yes", "No", "Yes", "Yes" }
Returns: 216000
9
{"Yes", "Yes", "Yes", "Yes", "Yes", "No", "No", "No", "Yes" }
Returns: 362880
9
{"Yes", "Yes", "Yes", "Yes", "No", "Yes", "Yes", "Yes", "Yes" }
Returns: 362880
5
{"Yes", "Yes", "Yes", "No", "No", "No", "No", "Yes" }
Returns: 10320
7
{"Yes", "Yes", "Yes", "No", "No", "No", "No", "Yes", "No" }
Returns: 463680
9
{"Yes", "Yes", "Yes", "Yes", "No", "No", "No", "No", "No" }
Returns: 362880
5
{"Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes" }
Returns: 834120
4
{"No", "Yes", "Yes", "No", "Yes", "Yes", "No", "No", "Yes" }
Returns: 3264
7
{"Yes", "Yes", "Yes", "No", "Yes", "No", "No", "Yes", "Yes" }
Returns: 559440
3
{"Yes", "No", "No", "Yes" }
Returns: 12
4
{"Yes", "No", "No", "No", "Yes", "Yes", "Yes", "Yes" }
Returns: 1704
4
{"Yes", "Yes", "No", "No", "Yes", "Yes", "Yes", "Yes", "Yes" }
Returns: 8736
4
{"Yes", "No", "Yes", "Yes", "Yes", "No", "No", "Yes", "No" }
Returns: 3264
9
{"No", "No", "No", "No", "No", "No", "No", "No", "Yes" }
Returns: 362880
9
{"No", "Yes", "Yes", "No", "No", "Yes", "No", "Yes", "Yes" }
Returns: 362880
6
{"No", "Yes", "No", "Yes", "No", "No", "No", "No" }
Returns: 57600
8
{"Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "Yes" }
Returns: 1451520
4
{"No", "No", "No", "No", "No", "No", "No", "No", "Yes" }
Returns: 23184
7
{"Yes", "Yes", "Yes", "Yes", "Yes", "Yes", "No", "No", "No" }
Returns: 559440