当前位置:网站首页>Find the number of permutations
Find the number of permutations
2022-06-13 02:33:00 【Prodigal son's private dishes】
Here you are Different An array of integers nums , And a target integer target . Please start from nums Find and return the sum of target The number of element combinations of .
The data of the questions ensure that the answers are in line with 32 Bit integer range .
Example 1:
Input :nums = [1,2,3], target = 4 Output :7 explain : All possible combinations are :
(1, 1, 1, 1)
(1, 1, 2)
(1, 2, 1)
(1, 3)
(2, 1, 1)
(2, 2)
(3, 1)
Please note that , Different sequences are considered as different combinations .Example 2:
Input :nums = [9], target = 3 Output :0
Code
class Solution {
public int combinationSum4(int[] nums, int target) {
int[] dp = new int[target+1];
dp[0] = 1;
for(int i = 0; i <= target; i++){
for(int j = 0; j < nums.length; j++){
if(i >= nums[j]){
dp[i] += dp[i-nums[j]];
}
}
}
return dp[target];
}
}
边栏推荐
- The fastest empty string comparison method C code
- 1000 fans ~
- [pytorch]fixmatch code explanation (super detailed)
- What are the differences in cache/tlb?
- Introduction to easydl object detection port
- 03 recognize the first view component
- [open source] libinimini: a minimalist ini parsing library for single chip computers
- 在IDEA使用C3P0連接池連接SQL數據庫後卻不能顯示數據庫內容
- A real-time target detection model Yolo
- [analysis notes] source code analysis of siliconlabs efr32bg22 Bluetooth mesh sensorclient
猜你喜欢

speech production model

02 优化微信开发者工具默认的结构

Thesis reading - autovc: zero shot voice style transfer with only autoencoder loss

Paper reading - group normalization

Yovo3 and yovo3 tiny structure diagram

Mbedtls migration experience

05 tabBar导航栏功能

Port mapping between two computers on different LANs (anydesk)

1、 Set up Django automation platform (realize one click SQL execution)
![[pytorch] kaggle image classification competition arcface + bounding box code learning](/img/1e/5e921987754da1e1750acdadb36849.jpg)
[pytorch] kaggle image classification competition arcface + bounding box code learning
随机推荐
Understanding and thinking about multi-core consistency
[reading paper] generate confrontation network Gan
01 初识微信小程序
L1 regularization and its sparsity
[keras] train py
(novice to) detailed tutorial on machine / in-depth learning with colab from scratch
03 认识第一个view组件
重定向设置参数-RedirectAttributes
Laptop touch pad operation
Leetcode 93 recovery IP address
Mbedtls migration experience
Basic principle of bilateral filtering
Leetcode 926. Flip string to monotonically increasing [prefix and]
1000 fans ~
An image is word 16x16 words: transformers for image recognition at scale
Example 4 linear filtering and built-in filtering
Opencv 08 demonstrates the effect of opening and closing operations of erode, dilate and morphological function morphologyex.
03 recognize the first view component
[pytorch] kaggle large image dataset data analysis + visualization
For loop instead of while loop - for loop instead of while loop