Given a string, what is the minimum number of adjacent swaps required to convert a string into a palindrome. If not possible, return -1.
Example 1:
Input: "mamad"
Output: 3
Example 2:
angular.module('cocoApp') | |
.directive('goBack', function () { | |
return { | |
restrict: 'A', | |
link: function (scope, element, attr) { | |
element.on('click', function () { | |
history.back(); | |
scope.$apply(); | |
}) | |
} |
@import "~node_modules/bootstrap/scss/_variables.scss"; | |
@mixin border-radius($radius) { | |
-webkit-border-radius: $radius; | |
-moz-border-radius: $radius; | |
-ms-border-radius: $radius; | |
border-radius: $radius; | |
} | |
@mixin transition($prop) { |
function possibilities (signals) { | |
var atoms = { | |
".": "E", | |
"-": "T", | |
"I": { | |
".": "S", | |
"-": "U" | |
}, | |
"A": { | |
".": "R", |
type Frequency = { [key: string]: number }; | |
function minDeletions(s: string): number { | |
const stringArr: string[] = s.split(''); | |
// Get the character frequencies | |
const freq: Frequency = {}; | |
stringArr.map((str) => { | |
freq[str] = Number(freq?.[str] || 0) + 1; | |
}); |
Given a string, what is the minimum number of adjacent swaps required to convert a string into a palindrome. If not possible, return -1.
Example 1:
Input: "mamad"
Output: 3
Example 2:
Arrays: move zeros to the left Given an integer array, move all elements that are 0 to the left while maintaining the order of other elements in the array. The array has to be modified in-place.
Example:
Given - [1, 10, 20, 0, 59, 63, 0, 88, 0]
Result - [0, 0, 0, 1, 10, 20, 59, 63, 88]
https://leetcode.com/problems/next-permutation/
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such an arrangement is not possible, it must rearrange it as the lowest possible order (i.e., sorted in ascending order).
The replacement must be in place and use only constant extra memory.
#!/usr/bin/env node | |
let fs = require('fs'); | |
let path = require('path'); | |
let args = process.argv.slice(2); | |
//console.log(args); | |
let parseArgs = (args) => { | |
let parsed = {}; |