Created
September 7, 2024 14:11
-
-
Save trycf/90bfd42737b8135a99dc7321778d51ba to your computer and use it in GitHub Desktop.
TryCF Gist
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
<cfscript> | |
function calc( a, k ){ | |
s = getTickCount(); | |
dump(a); | |
st = {}; | |
for (var aa in a){ | |
if (!structKeyExists(st, aa)) | |
st[aa] = 0; | |
st[aa]++; | |
} | |
dump(st); | |
b = structSort(st, "numeric", "asc") | |
dump(b); | |
c = arraySlice(b, k+1); | |
echo(len(c)); | |
echo(getTickCount()-s & "<hr>") | |
} | |
calc ([5,5,4], 1); | |
calc ([4,4,5], 1); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment