[March-week2] Flip card
-
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); } } ```
- using Euclidean algorithm
- Elvis Operation
- using Elvis Operation return
str?.length
if null then -1Solution
```kotlin val lenOfString = str?.length ?: -1 ```
- using Elvis Operation return
- Safe Call
- Get string length using
safe Call
variable name isstr
Solution
```kotlin str?.length ```
- Get string length using
Leave a comment