FrogJmp 發表於 2023-02-13 | 分類於 codility , Time Complexity problemsolution12345678910111213// you can use includes, for example:// #include <algorithm>// you can write to stdout for debugging purposes, e.g.// cout << "this is a debug message" << endl;int solution(int X, int Y, int D) { // write your code in C++14 (g++ 6.2.0) Y -=X; if(Y%D!=0) return Y/D+1; else return Y/D;} analysis time complexity O(1) space complexity O(1)