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
/************* | |
* colors.js * | |
************* | |
* | |
* You're almost at the exit. You just need to get past this | |
* color lock. | |
* | |
* Changing your environment is no longer enough. You must | |
* learn to change yourself. I've sent you a little something | |
* that should help with that. |
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
有一存有整数的数组 A[n] (n <= 2^31 - 1, 但需要的话可以再扩大), 其中 0 <= i, A[i] <= n-1 且 i!=j 时 A[i]!=A[j] (即一个排列). 用你认为*最高效*的方法求 B=A^(-1) (即对范围内满足 A[B[i]]=i 的 B) |
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
/** | |
* Arbitrary-length tuples | |
* ======================= | |
* | |
* Working with tuples of unknown length in TypeScript is a pain. Most library authors fall back on enumerating all possible | |
* tuple lengths up to a threshold (see an example here https://github.com/pelotom/runtypes/blob/fe19290d375c8818d2c52243ddc2911c8369db37/src/types/tuple.ts ) | |
* | |
* In this gist, I'm attempting to leverage recursion to provide support for arbitrary length tuples. This has the potential | |
* to make some kinds of declarative APIs nicer and enhance type inference in some cases. | |
* This example shows how to take a variable-length tuple as an input, transform each of its types and use the resulting |