g2601_2700.s2620_counter.solution.ts Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java Show documentation
Show all versions of leetcode-in-java Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
The newest version!
// #Easy #2023_08_31_Time_43_ms_(98.60%)_Space_42.2_MB_(91.27%)
function createCounter(n: number): () => number {
const fun = function () {
n++
return n - 1
}
return fun
}
/*
* const counter = createCounter(10)
* counter() // 10
* counter() // 11
* counter() // 12
*/
export { createCounter }
© 2015 - 2024 Weber Informatics LLC | Privacy Policy