This one is quite easy.
====================================================
Complexity:
- expected worst-case time complexity is O(1);
- expected worst-case space complexity is O(1).
====================================================
int solution(int X, int Y, int D) {
int distance = Y - X;
return distance % D == 0 ? distance / D : distance / D + 1;
}
0 件のコメント:
コメントを投稿