SHARE
TWEET

Untitled

a guest Jan 21st, 2020 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Kierrokset {
  2.  
  3.     int laske(int[] t) {
  4.  
  5.         int n = t.length;
  6.         int[] kohta = new int[n+1];
  7.  
  8.         for (int i = 0; i < n; i++) {
  9.             kohta[t[i]] = i;
  10.         }
  11.  
  12.         int tulos = 1;
  13.  
  14.         for (int i = 2; i <= n; i++) {
  15.             if (kohta[i] < kohta[i-1]) tulos++;
  16.         }
  17.         return tulos;
  18.  
  19.     }
  20.  
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top