mirror of
https://github.com/TheAlgorithms/C.git
synced 2026-09-23 07:24:45 +00:00
Merge pull request #490 from andre143/master
Adding leetcode Rotate Array (189.c)
This commit is contained in:
@@ -44,6 +44,7 @@ LeetCode
|
||||
|160|[Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists/) | [C](./src/160.c)|Easy|
|
||||
|169|[Majority Element](https://leetcode.com/problems/majority-element/) | [C](./src/169.c)|Easy|
|
||||
|173|[Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator/) | [C](./src/173.c)|Medium|
|
||||
|189|[Rotate Array](https://leetcode.com/problems/rotate-array) | [C](./src/189.c)|Easy|
|
||||
|190|[Reverse Bits](https://leetcode.com/problems/reverse-bits/) | [C](./src/190.c)|Easy|
|
||||
|191|[Number of 1 Bits](https://leetcode.com/problems/number-of-1-bits/) | [C](./src/191.c)|Easy|
|
||||
|201|[Bitwise AND of Numbers Range](https://leetcode.com/problems/bitwise-and-of-numbers-range/) | [C](./src/201.c)|Medium|
|
||||
|
||||
11
leetcode/src/189.c
Normal file
11
leetcode/src/189.c
Normal file
@@ -0,0 +1,11 @@
|
||||
void rotate(int* nums, int numsSize, int k){
|
||||
for(int i = 1; i <= k; i++){
|
||||
int j;
|
||||
int lastElement;
|
||||
lastElement = nums[numsSize - 1];
|
||||
for(j = numsSize - 1; j > 0; j--){
|
||||
nums[j] = nums[j - 1];
|
||||
}
|
||||
nums[0] = lastElement;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user