Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Kierrokset {
- int laske(int[] t) {
- int n = t.length;
- int[] kohta = new int[n+1];
- for (int i = 0; i < n; i++) {
- kohta[t[i]] = i;
- }
- int tulos = 1;
- for (int i = 2; i <= n; i++) {
- if (kohta[i] < kohta[i-1]) tulos++;
- }
- return tulos;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement