diff options
| author | Steve Lee <me@xiangyangli.com> | 2017-12-26 01:33:40 +0800 |
|---|---|---|
| committer | Steve Lee <me@xiangyangli.com> | 2017-12-26 01:33:40 +0800 |
| commit | 79a9c52fa923fc78074d88463449a8b7f95ca3ef (patch) | |
| tree | 80c2b596a7c41124845771dca99abd364e89d4c4 /Computer_Science/leetcode/46-permutations.c~ | |
| parent | 2e0e0f39d49296f0ffb99aea533a527174521d61 (diff) | |
| download | 42-79a9c52fa923fc78074d88463449a8b7f95ca3ef.tar.xz 42-79a9c52fa923fc78074d88463449a8b7f95ca3ef.zip | |
update leetcode solution
Diffstat (limited to 'Computer_Science/leetcode/46-permutations.c~')
| -rw-r--r-- | Computer_Science/leetcode/46-permutations.c~ | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Computer_Science/leetcode/46-permutations.c~ b/Computer_Science/leetcode/46-permutations.c~ new file mode 100644 index 0000000..5a7f346 --- /dev/null +++ b/Computer_Science/leetcode/46-permutations.c~ @@ -0,0 +1,18 @@ +/** + * Return an array of arrays of size *returnSize. + * Note: The returned array must be malloced, assume caller calls free(). + */ +int** permute(int* nums, int numsSize, int* returnSize) { + for(int i = 0; i < numsSize; i++) { + backtracking(nums, i + 1, numsSize, returnSize); + } +} + +void backtracking(int* nums, int start, int numsSize, int* returnSize) +{ + if(start == numsSize) return; + else if(start = numsSize -1) { + //add all to result + } else + backtracking(nums, i + 1, numsSize, returnSize); +} |
