g2601_2700.s2666_allow_one_function_call.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_09_09_Time_50_ms_(88.35%)_Space_43.1_MB_(19.45%)
type Fn = (...args: any[]) => any
function once(fn: Fn): Fn {
let wasCalled = false
return function (...args) {
if (!wasCalled) {
wasCalled = true
return fn(...args)
}
}
}
export { once }
© 2015 - 2024 Weber Informatics LLC | Privacy Policy