Created
September 7, 2024 14:12
-
-
Save trycf/7a69d7a8a224629c6c459a2665df92de 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) & " unique values<br>"); | |
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