4 ms·
Check if one string is a rotation of another string
- raganwald 16y agoWhy is this kind of thing on HN? I don't mean that it isn't of interest to Hackers... I find it extremely interesting! But StackOverflow has a community and a discussion feature. So if I want to comment on the question or its answers I can do that right there. And any comment on here is not visible to people who answer the question there. Having a separate conversation is useful if the HN community is strongly disjoint from the source community, that way you get a completely different flavour to the commentary. For example, I'm glad when I see one of my own posts on HN and on proggit, I get two completely different kinds of feedback from the comments, and that's a benefit to me as an author and I suspect to the communities. But is HN completely disjoint from StackOverflow where a simple programming question is concerned? Is it a net benefit to have two separate comment streams?
- mbrubeck 16y agoSome people (like you, it seems) see HN primarily as a place to discuss things. Others see it primarily as a place to discover things. For the latter group, this belongs on HN because they would not have seen it otherwise.
- J3L2404 16y agoI posted this because its an elegant code snippet. Maybe the majority of users here are already familiar with this pattern, but being fairly new to programming I found it to be a good solution. I read a blogpost by Jake Voytko last year that had a similar goal but cast the strings to integers and was much more complicated. The SO algorithm is probably less efficient depending on the implementation of the subString method, but I imagine it is pretty close to optimal, does anyone know of a better algorithm?