This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countTriplets(arr, r) { | |
let pairs = {} | |
let freq = {} | |
let count = 0 | |
arr.reverse().forEach(a => { | |
let b = a * r | |
if (b in pairs) { | |
count += pairs[b] | |
} | |
if (b in freq) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post('/upload/photo', async (ctx, next) => { | |
// Check if a file was sent | |
if (!ctx.request.body || !ctx.request.body.files || !ctx.request.body.files.file || !ctx.request.body.files.file.path) { | |
throw new Error('No file provided.'); | |
} | |
const file = ctx.request.body.files.file; | |
// Save the file locally on your server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class ExampleDirective { | |
constructor() { | |
this.template = '<div>{{ctrl.name}}</div>'; | |
this.restrict = 'E'; | |
this.scope = {}; | |
this.controller = ExampleDirectiveController; | |
this.controllerAs = 'ctrl'; | |
this.bindToController = true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = []; | |
for (var i = 0; i < source.length; ++i) { | |
for (var j = 0; j < source[i].length; ++j) | |
result.push(source[i][j]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = []; | |
for (var i = 0; i < source.length; ++i) { | |
for (var j = 0; j < source[i].length; ++j) | |
result.push(source[i][j]); | |
} |