Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 517fec4

Browse files
Merge pull request #54 from amejiarosario/chore/sematic-release
feat(heap): add min/max/median-heaps
2 parents 28da0e1 + 7e19bdc commit 517fec4

File tree

15 files changed

+8169
-11150
lines changed

15 files changed

+8169
-11150
lines changed

‎CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Just as in the **subject**, use the imperative, present tense: "change" not "cha
165165
The body should include the motivation for the change and contrast this with previous behavior.
166166

167167
### Footer
168-
The footer should contain any information about **Breaking Changes** and is also the place to
168+
The footer should contain any information about **BREAKING CHANGES** and is also the place to
169169
reference GitHub issues that this commit **Closes**.
170170

171171
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*eslint-disable */
2+
3+
function reverse (arr, i, j) {
4+
while (i < j) {
5+
[arr[i], arr[j]] = [arr[j], arr[i]];
6+
i++;
7+
j--;
8+
}
9+
}
10+
11+
function backtracking(array, start = 0) {
12+
let permutations = [array];
13+
14+
for (let i = start; i < array.length - 1; i++) {
15+
for (let j = i + 1; j < array.length; j++) {
16+
reverse(array, i, j);
17+
permutations = permutations.concat(backtracking(array, i + 1));
18+
reverse(array, i, j);
19+
}
20+
}
21+
22+
return permutations;
23+
}
24+
25+
function minPermutations(arr) {
26+
return backtracking(arr);
27+
}
28+
29+
module.exports = minPermutations;
30+
31+
//*/
32+
// console.log(backtracking([1,2,3]));
33+
// console.log(backtracking([1,2,3,4]));
34+
//*/
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const fn = require('./min-permutations');
2+
3+
describe('Min Permutations', () => {
4+
it('should work', () => {
5+
expect(fn([1,2,3])).toEqual();
6+
});
7+
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /