unknown Interview Question for Software Developers
- 0of 0 votes
AnswersConsider a string A containing exactly X characters. A variant of A, A(k), can be obtained by doing a cyclic shift of A starting from position k (0 <= k < X). The number of characters after the shift in A(k) will remain the same as they were in A. Every j-th character (0 <= j <= X-1) of A(k) is equal to (k+j)%X character of A. We will call A a classic word if there are exactly M positions k such that A(k) = A
- Abhishek.Mathur.CA September 30, 2016 in United States
You are given array Q containing exactly R strings. For each permutation s = (s[0], s[1], ..., s[R-1]) of integers between 0 and R-1, inclusive, we can define a string generated by this permutation as a concatenation Q[s[0]] + Q[s[1]] + ... + Q[s[R-1]]. Find the number of permutations that generate classic words. All indices in this problem are 0-based
Constraints
Set Q will contain between 1 and 8 elements, inclusive. Each element will have 1 to 20 characters, inclusive
M will be between 1 and 200, inclusive
Input Format
Line 1: comma separated strings representing set Q
Line 2: Integer M
Output Format
Number of permutations that generate classic words
Sample Input
CD,QCCD,QC
2
Sample Output
3
Explanation
The classic words are "CDQCCDQC" and "QCCDQCCD". Permutation 0, 1, 2 generates the first, and 1, 2, 0 and 2, 0, 1 generate the second| Report Duplicate | Flag | PURGE
unknown Software Developer