You are viewing a single comment's thread. Return to all comments →
Time Complexity: O(n) <\br>
Space Complexity: O(n)
int* rotateLeft(int d, int arr_count, int* arr, int* result_count) { int* res_arr = (int* )malloc(arr_count*sizeof(int)); *result_count = 0; for (int i = 0; i<arr_count; i++){ res_arr[i] = arr[(i+d)%arr_count]; (*result_count) ++; } return res_arr; }
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Left Rotation
You are viewing a single comment's thread. Return to all comments →
Time Complexity: O(n) <\br>
Space Complexity: O(n)