A list of useful commands for the FFmpeg command line tool.
Download FFmpeg: https://www.ffmpeg.org/download.html
Full documentation: https://www.ffmpeg.org/ffmpeg.html
/* | |
A non-empty zero-indexed array A consisting of N integers is given. Array A represents numbers on a tape. | |
Any integer P, such that 0 < P < N, splits this tape into two non-empty parts: A[0], A[1], ..., A[P − 1] and A[P], A[P + 1], ..., A[N − 1]. | |
The difference between the two parts is the value of: |(A[0] + A[1] + ... + A[P − 1]) − (A[P] + A[P + 1] + ... + A[N − 1])| | |
In other words, it is the absolute difference between the sum of the first part and the sum of the second part. | |
*/ |
Lesson 1 - Iterations | |
- BinaryGap - https://codility.com/demo/results/trainingU2FQPQ-7Y4/ | |
Lesson 2 - Arrays | |
- OddOccurrencesInArray - https://codility.com/demo/results/trainingFN5RVT-XQ4/ | |
- CyclicRotation - https://codility.com/demo/results/trainingSH2W5R-RP5/ | |
Lesson 3 - Time Complexity | |
- FrogJmp - https://codility.com/demo/results/training6KKWUD-BXJ/ | |
- PermMissingElem - https://codility.com/demo/results/training58W4YJ-VHA/ |
// Solution for CountNonDivisible (Codility) | |
// Not the best, just O(N^2)... | |
// https://codility.com/programmers/lessons/11-sieve_of_eratosthenes/count_non_divisible/ | |
function solution(A) { | |
// write your code in JavaScript (Node.js 6.4.0) | |
const divisors = A.map(e => 0); | |
for (let i = 0; i<A.length; i++) { |
//Solution of https://gist.github.com/lubien/1f09a53a4b5607377166c58a7eb49ae0 | |
const solve = (people, umbrellas) => { | |
const biggerUmbrella = Math.max(...umbrellas) | |
const remain = people % biggerUmbrella | |
const peopleThatFit = Math.floor(people / biggerUmbrella) | |
if (remain >= 1 && umbrellas.length === 1) { | |
return -1 | |
} else { |
/** | |
* Finds element without a pair in an unsorted array of integers | |
* @param {array} A | |
* @return {int} element without a pair | |
*/ | |
function solution(A) { | |
let result = 0; | |
for (let element of A) { | |
// Apply Bitwise XOR to the current and next element |
function solution(X, A) { | |
// write your code in JavaScript (Node.js 6.4.0) | |
let sequence = [0]; | |
let position = -1; | |
let counter = 0; | |
if (X === 1 && A[0] === 1) | |
return 0; |
A list of useful commands for the FFmpeg command line tool.
Download FFmpeg: https://www.ffmpeg.org/download.html
Full documentation: https://www.ffmpeg.org/ffmpeg.html
const isAnagram => (s, t) { | |
var lens = s.length, | |
lent = t.length; | |
if(lens !== lent) return false; | |
if(typeof s !== 'string' || typeof t !== 'string') return false; | |
if(lens === 0 && lent === 0) return true; | |
var charmap = {}; | |
for(let i=0; i<lens; i++){ | |
charmap[s[i]] = charmap[s[i]] ? charmap[s[i]]+1: 1; |
/* | |
Diagonal Difference Solution. | |
sample matrix = [[1,2,3], [4,5,6], [7,8,9]] | |
*/ | |
function diagonalDifference(matrix) { | |
// length of input matrix. | |
const length = matrix.length; | |
let diagonal1 = 0, diagonal2 = 0; | |
// Looping through the array and summing the diagonals. |