C Programming Assignment-1
C Programming Assignment-1
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of
the two sorted arrays.
Example 1:
Example 2:
Constraints:
● nums1.length == m
● nums2.length == n
● 0 <= m <= 1000
● 0 <= n <= 1000
● 1 <= m + n <= 2000
● -106 <= nums1[i], nums2[i] <= 106
2. Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value
to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0.
Assume the environment does not allow you to store 64-bit integers (signed or unsigned).
Example 1:
Input: x = 123
Output: 321
Example 2:
Input: x = -123
Output: -321
Example 3:
Input: x = 120
Output: 21
Constraints:
Example 1:
Example 2:
The integer division should truncate toward zero, which means losing its fractional part. For
example, 8.345 would be truncated to 8, and -2.7335 would be truncated to -2.
Note: Assume we are dealing with an environment that could only store integers within the 32-bit
signed integer range: [−231, 231 − 1]. For this problem, if the quotient is strictly greater than 231 - 1,
then return 231 - 1, and if the quotient is strictly less than -231, then return -231.
Example 1:
Example 2:
Constraints:
divisor != 0
5. Given an array of distinct integers candidates and a target integer target, return a list of all
unique combinations of candidates where the chosen numbers sum to target. You may return
the combinations in any order.
The same number may be chosen from candidates an unlimited number of times. Two combinations
are unique if the frequency of at least one of the chosen numbers is different.
The test cases are generated such that the number of unique combinations that sum up to target is
less than 150 combinations for the given input.
Example 1:
Example 2:
Example 3:
Constraints:
Example 1:
Example 2:
Example 3:
Constraints:
Example 1:
Input: x = 2.00000, n = 10
Output: 1024.00000
Example 2:
Input: x = 2.10000, n = 3
Output: 9.26100
Example 3:
Input: x = 2.00000, n = -2
Output: 0.25000
Explanation: 2 -2 = ½ 2 = 1/4 = 0.25
Constraints:
n is an integer.
Example 1:
Output: 2
Example 2:
Output: 1
Example 3:
Output: 4
Constraints:
Example 1:
Output:
[[1,1,2],
[1,2,1],
[2,1,1]]
Example 2:
Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
Constraints:
Note that the same word in the dictionary may be reused multiple times in the segmentation.
Example 1:
Example 2:
Example 3:
Constraints:
Example 1:
Example 2:
Constraints:
Note:
● Note that in some languages, such as Java, there is no unsigned integer type. In this case,
the input will be given as a signed integer type. It should not affect your implementation, as
the integer's internal binary representation is the same, whether it is signed or unsigned.
● In Java, the compiler represents the signed integers using 2's complement notation.
Therefore, in Example 3, the input represents the signed integer. -3.
Example 1:
Input: n = 00000000000000000000000000001011
Output: 3
Explanation: The input binary string 00000000000000000000000000001011 has a total of three '1'
bits.
Example 2:
Input: n = 00000000000000000000000010000000
Output: 1
Explanation: The input binary string 00000000000000000000000010000000 has a total of one '1' bit.
Example 3:
Input: n = 11111111111111111111111111111101
Output: 31
Explanation: The input binary string 11111111111111111111111111111101 has a total of thirty one '1'
bits.
Constraints: