AlgoDaily Solution
1Locked, only available for premium members.
Community Solutions
Community solutions are only available for premium users.
Access all course materials today
The rest of this tutorial's contents are only available for premium members. Please explore your options at the link below.
xxxxxxxxxx
54
var ob1;
class LinearApproach{
nextPermutation(nums) {
// write your code here
return nums;
}
}
function tests() {
ob1 = new LinearApproach();
var assert = require('assert').strict;
let pass = 0;
try {
assert.deepStrictEqual(ob1.nextPermutation([1,2,3]), [1,3,2]);
console.log( 'Test1 - PASSED ');
pass += 1;
} catch (err) {
console.log(err);
}
try {
assert.deepStrictEqual(ob1.nextPermutation([1, 2, 5, 4, 3]), [ 1, 3, 2, 4, 5 ]);
console.log( 'Test2 - PASSED' );
pass += 1;
} catch (err) {
OUTPUT
Results will appear here.