This file contains hidden or 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
| /** | |
| * Definition for a binary tree node. | |
| * class TreeNode { | |
| * val: number | |
| * left: TreeNode | null | |
| * right: TreeNode | null | |
| * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { | |
| * this.val = (val===undefined ? 0 : val) | |
| * this.left = (left===undefined ? null : left) | |
| * this.right = (right===undefined ? null : right) |
This file contains hidden or 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 jumpingOnClouds(arr) { | |
| const length = arr.length; | |
| let jumps = 0; | |
| for(let i = 0; i <= length; i++) { | |
| const canIJumpTwoClouds = arr[i + 2] === 0; | |
| if (canIJumpTwoClouds) { | |
| jumps += 1; | |
| i += 1; | |
| continue; |
This file contains hidden or 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 n = 9; | |
| var ar = [10, 20, 20, 10, 10, 30, 50, 10, 20] | |
| function sockMerchant(n, arr) { | |
| const hash = new Map(); | |
| let count = 0; | |
| for(let i = 0; i < n; i++) { | |
| const sock = arr[i]; | |
| if (hash.get(sock) == 1) { |
This file contains hidden or 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
| // retorna undefined | |
| function bad() { | |
| return | |
| 'bad'; | |
| } | |
| function good() { | |
| return 'good' | |
| } |
This file contains hidden or 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
| const bar = 'bar' | |
| let foo = 'baz' | |
| const bazzz = 'baaarrr', | |
| fooos = 'baaam' | |
| function hello(world) { | |
| let greeting = 'Hello ' | |
| if (world) |
This file contains hidden or 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
| const foo = 100 | |
| const bar = 20 | |
| // La línea es - o ++ (en cuyo caso disminuirá / incrementará el siguiente token). | |
| bar | |
| ++ | |
| foo | |
| /* | |
| La intención es que se interptete así | |
| bar++; |
This file contains hidden or 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
| // El IIFE (Immediately-Invoked Function Expression) al ejecutarse añade el primer frame al stack de llamada | |
| (() => { | |
| // Añade un frame al stack de llamada | |
| console.log('1. Hola'); | |
| // WebApi: Agrega un mensaje a la cola | |
| setTimeout(() => { | |
| console.log('2. Mundo'); | |
| }); |
This file contains hidden or 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
| while( queue.esperaPorMensaje() ) { | |
| queue.procesaSiguienteMensaje(); | |
| } |
This file contains hidden or 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 segundoAlStack() { | |
| var foo = 20 * 100; | |
| return foo; | |
| } | |
| function primeroAlStack() { | |
| var bar = 5; | |
| var foo = segundoAlStack(); | |
| return bar + foo; |
This file contains hidden or 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
| (() => { | |
| console.log('1. Hola'); | |
| setTimeout(() => { | |
| console.log('2. Mundo'); | |
| }); | |
| setTimeout(() => { | |
| console.log('3. A todos'); | |
| }, 0); |
NewerOlder