我正在尝试解决经典的硬币找零(动态)问题。
为了使用动态方法找到所有独特组合的数量以从无限面额的硬币中获得总和,我使用了以下方法:
/*
n - number of coins
arr[] - coin denominations
x - total sum
dp[] - array to store number of combinations at index i.
*/
for (int j = 0; j < n; j++)
for (int i = 1; i <= x; i++)
if (arr[j] <= i)
dp[i] = (long) ((dp[i] + dp[i - arr[j]]) % (1e9 + 7));
Run Code Online (Sandbox Code Playgroud)
这给了我所有唯一可能的combinations计数:
例如:
Input:
n=3 x=9
Coins: 2 3 5
Output:
3
Run Code Online (Sandbox Code Playgroud)
到目前为止,一切都很好。但我观察到,只需交换上面代码片段中的循环,我就得到了所有可能的结果permutations。
Input:
n=3 …Run Code Online (Sandbox Code Playgroud) 我正在使用此方法添加多个远程存储库 URL。我错误地使用此命令两次添加了相同的远程网址:
git remote set-url origin --push --add <a remote>
Run Code Online (Sandbox Code Playgroud)
所以现在git remote -v显示这个:
origin https://github.com/<user>/<repo>.git (fetch)
origin https://github.com/<user>/<repo>.git (push) // remote-1
origin https://github.com/<user>/<repo>.git (push) // duplicate reference to same remote-1
origin https://bitbucket.com/<user>/<repo>.git (push) // remote-2
Run Code Online (Sandbox Code Playgroud)
所以现在,每当我推送时,git 都会推送 3 次,假设有 3 个 URL。
我如何删除这个重复的 URL,同时保留原始的和新的远程引用。