[March-week2] Flip card

less than 1 minute read

  1. how to get gcd, lcm

    • using Euclidean algorithm
      solution ``` C++ class Solution { public : int gcd(int a, int b) { int t = 0; while(b != 0) { t = b; b = a%b; a = t; } return a } int lcm(int a, int b) { return (a * b) / gcd(a, b); } } ```
  2. Elvis Operation
    • using Elvis Operation return str?.length if null then -1
      Solution ```kotlin val lenOfString = str?.length ?: -1 ```
  3. Safe Call
    • Get string length using safe Call variable name is str
      Solution ```kotlin str?.length ```

Leave a comment