Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 31st, 2020 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int countMaxCross(string& riverMap)
  2. {
  3.     int n = riverMap.length()+1;
  4.     int lArr[riverMap.length()];
  5.     int rArr[riverMap.length()];
  6.     for (int j = 0; j <n; ++j)
  7.     {
  8.         lArr[j] = 0;
  9.         rArr[j] = 0;
  10.     }
  11.     rArr[0]=1;
  12.     int k = 1;
  13.     char currChar;
  14.     while (k <= n)
  15.     {
  16.         currChar = riverMap[k - 1];
  17.         switch (currChar)
  18.         {
  19.             case 'B':
  20.                 lArr[k] = lArr[k - 1] + 1;
  21.                 rArr[k] = rArr[k - 1] + 1;
  22.                 break;
  23.             case 'R':
  24.                 lArr[k] = lArr[k - 1];
  25.                 rArr[k] = rArr[k - 1] + 1;
  26.                 break;
  27.             default://'L'
  28.                 lArr[k] = lArr[k - 1] + 1;
  29.                 rArr[k] = rArr[k - 1];
  30.                 break;
  31.         }
  32.         rArr[k] = (lArr[k] + 1 < rArr[k]) ? (lArr[k] + 1) : rArr[k];
  33.         lArr[k] = (rArr[k] + 1 < lArr[k]) ? (rArr[k] + 1) : lArr[k];
  34.         k++;
  35.     }
  36.  
  37.     return rArr[n];
  38. }
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