Hacker News new | past | comments | ask | show | jobs | submit login

You could always just write out all permutations and train a network on recognizing the sorted one ;-)



A storage requirement of O(n!)

Sorting a mere 13 items of 1-byte each would require 6.2 GB of storage.


We just generate them on the fly - after all we're not stupid ;-)

https://en.wikipedia.org/wiki/Permutation#Algorithms_to_gene...

.. and there

"Generation in lexicographic order"

This algorithm only requires you to hold the last permutation in memory to obtain a new (distinct) one.


Good interview question ;)




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: