C Programs
C Programs
Maximum Subarray
Example 1:
Constraints:
Follow up: If you have figured out the O(n) solution, try
coding another solution using the divide and conquer
approach, which is more subtle.
Solution
#include <stdio.h>
#include <stdlib.h>
int main() {
int numsSize;
return 0;
}
4. Median of Two Sorted Arrays
Given two sorted arrays nums1 and nums2 of size m and n
respectively, return the median of the two sorted arrays.
Example 1:
Constraints:
nums1.length == m
nums2.length == n
0 <= m <= 1000
0 <= n <= 1000
1 <= m + n <= 2000
-106 <= nums1[i], nums2[i] <= 106
Solution
#include <stdio.h>
#include <stdlib.h>
int main() {
int m, n;
return 0;
}
11. Container With Most Water
Example 1:
Constraints:
n == height.length
2 <= n <= 105
0 <= height[i] <= 104
Solution
#include <stdio.h>
#include <stdlib.h>
return maxArea;
}
int main() {
int n;
return 0;
}
215. Kth Largest Element in an Array
Example 1:
Constraints:
Solution
#include <stdio.h>
#include <stdlib.h>
return 0;
}
518. Coin Change II
Example 1:
Constraints:
Solution
#include <stdio.h>
#include <stdlib.h>
int main() {
int amount;
int coinsSize;
return 0;
}
1365. How Many Numbers Are Smaller
Than the Current Number
Given the array nums, for each nums[i] find out how many
numbers in the array are smaller than it. That is, for
each nums[i] you have to count the number of valid j's
such that j != i and nums[j] < nums[i].
Example 1:
Constraints:
return result;
}
int main() {
int numsSize;
int *nums;
int returnSize;
return 0;
}
1450. Number of Students Doing
Homework at a Given Time
Given two integer arrays startTime and endTime and given
an integer queryTime.
Example 1:
Constraints:
startTime.length == endTime.length
1 <= startTime.length <= 100
1 <= startTime[i] <= endTime[i] <= 1000
1 <= queryTime <= 1000
Solution
#include <stdio.h>
#include <stdlib.h>
return count;
}
int main() {
int n, queryTime;
return 0;
}