6 kyu
Prefix Permutation
53 of 117medmelki
Description:
Given a sequence of integers of length n, print the number of prefix permutations within it.
A prefix permutation is an index P that satisfies :
- 0 <= P < N
- the sequence A[0], A[1], .....A[P] is a permutation of integers from 1 to P + 1
Example :
if given sequence is [2,1,3,5,4], then
[2] is NOT a permuation of [1]
[2,1] IS a permutation of [1,2]
[2,1,3] IS a permutation of [1,2,3]
[2,1,3,5] is NOT a permutation of [1,2,3,4]
[2,1,3,5,4] IS a permutation of [1,2,3,4,5]
and there are 3 prefix permutations
Performance
Algorithms
Similar Kata:
Stats:
Created | Oct 20, 2017 |
Published | Oct 20, 2017 |
Warriors Trained | 379 |
Total Skips | 13 |
Total Code Submissions | 1377 |
Total Times Completed | 117 |
Java Completions | 53 |
JavaScript Completions | 68 |
Total Stars | 7 |
% of votes with a positive feedback rating | 84% of 41 |
Total "Very Satisfied" Votes | 32 |
Total "Somewhat Satisfied" Votes | 5 |
Total "Not Satisfied" Votes | 4 |
Total Rank Assessments | 11 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |