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 longestCollatzSequence = limit => { | |
var numberWithHighestSequence = 3; | |
var highestSequenceIndex = 8; | |
/** | |
* "Uint32Array" automatically fill with "zeros" - avoid copyWithin/loop/map to set array with zero values | |
* | |
* Save between 20~25 ms | |
*/ | |
var arrayOfSequences = new Int32Array(limit); | |
arrayOfSequences[1] = 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
import { StatusCodes } from 'http-status-codes'; | |
const { id } = req.params; | |
const bookIndex = books.findIndex((book) => book.id === parseInt(id)); | |
const bookNotFound = bookIndex === -1; | |
if (bookNotFound) { | |
res.status(StatusCodes.NOT_FOUND).send(); | |
return; | |
} |