Given a string, find the number of different characters in it.
For s = "cabca"
, the output should be
differentSymbolsNaive(s) = 3
.
There are 3
different characters a
, b
and c
.
const path = require('path'); | |
const fs = require('fs'); | |
const NextFederationPlugin = require('@module-federation/nextjs-mf'); | |
const { FederatedTypesPlugin } = require('@module-federation/typescript'); | |
const MODULES = { | |
"host": { | |
"port": 3100 | |
}, | |
"home": { |
const numberOfCharInString = (c, s) => { | |
let [count, index] = [0, 0]; | |
while (true) { | |
index = s.indexOf(c, index); | |
if (index >= 0) { | |
++count; | |
++index; | |
} else break; | |
} | |
return count; |
// https://github.com/Stuk/jszip/issues/399 | |
JSZip.loadAsync(data).then(function (zip) { | |
var re = /(.jpg|.png|.gif|.ps|.jpeg)$/; | |
var promises = Object.keys(zip.files).filter(function (fileName) { | |
// don't consider non image files | |
return re.test(fileName.toLowerCase()); | |
}).map(function (fileName) { | |
var file = zip.files[fileName]; | |
return file.async("blob").then(function (blob) { |
# https://www.tutorialspoint.com/csharp/index.htm | |
# https://www.dotnetperls.com/ |
import grass.script as grass | |
grass.run_command('r.viewshed', | |
input='standard.dem', | |
output='viewshed', | |
coordinate=[observer_x, observer_y], | |
obs_elev=1.75, | |
tgt_elev=0.0, | |
memory=4098, | |
overwrite=True, |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Previous/Next Extent</title> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="//js.arcgis.com/3.21/esri/css/esri.css"> | |
<style> | |
html, body { | |
margin: 0; padding: 0; | |
width: 100%; height: 100%; |
Find the leftmost digit that occurs in a given string.
inputString = "var_1__Int"
, the output should befirstDigit(inputString) = '1'
;inputString = "q2q-q"
, the output should befirstDigit(inputString) = '2'
;inputString = "0ss"
, the output should befirstDigit(inputString) = '0'
.Given an array of equal-length strings, check if it is possible to rearrange the strings in such a way that after the rearrangement the strings at consecutive positions would differ by exactly one character.
For inputArray = ["aba", "bbb", "bab"]
, the output should be
stringsRearrangement(inputArray) = false
;
All rearrangements don't satisfy the description condition.
For inputArray = ["ab", "bb", "aa"]
, the output should be