3

So, I found a programming question while preparing for an interview on some site, to which there wasn't an answer available online anywhere.

I tried to solve the question myself and came up with a solution. But I'm wondering if my solution is the most optimal. Is it alright to post such externally asked question on Stack Overflow along with its answer? I'm confused as the question is available somewhere else and won't be unique. But the answer to it is not available anywhere else and is unique as I solved it on my own. I'm concerned if my question will be down voted if I post it.

--Update

So, I have asked the question on Code Review and have received a good response till now.

https://codereview.stackexchange.com/questions/92751/return-all-words-which-have-their-reverse-present-in-a-string

Wondering if the question would have received the same response on Stack Overflow as well.

10
  • 6
    If your question would just be the problem statement, then it's too broad. If your solution "works" and you want to ask if it's "optimal", then it's probably not appropriate for Stack Overflow. We're about fixing programming problems. You might find Code Review appropriate but I'm not sure about that. Look and see if there's similar on their site.
    – TZHX
    Jun 5, 2015 at 12:45
  • To be specific its a problem as: "Given a string of words return all words which have their reverse present". I solved it using Hash Map. I was wondering if I could simply put up the question and answer it myself and share with SO community. And other users might come up with better solutions if any. Jun 5, 2015 at 12:48
  • 7
    But if the question would just boil down to "Write code that does X" then it's not really a good fit for Stack Overflow.
    – TZHX
    Jun 5, 2015 at 12:50
  • In addition to all the above comments. Are you sure you have the right to repost the question? What are the licencing requirements of "some site" Jun 5, 2015 at 12:55
  • I found it on geeksforgeeks.org under their interviews section. Website is licensed under "Creative Commons". So, I believe I can freely ask the question and provide my answer. Will it help if I frame and put my programming question here on Meta to get an opinion? Jun 5, 2015 at 12:59
  • 3
    This might be appropriate for Programming Puzzles & Code Golf but you should check first, particularly since you want to ask about your solution instead of just asking the question.
    – BSMP
    Jun 5, 2015 at 13:43
  • To answer your updated "wondering", it would most likely have been closed on Stack Overflow, so, no the response would not have been the same ;) Jun 5, 2015 at 20:36
  • Not a dupe of that question. This is not about 'puzzles'.
    – Jan Doggen
    Aug 16, 2019 at 11:20
  • @JanDoggen the duplicate covers challenges as well, it's not only about puzzles (though if you prefer duplicate focused strictly on challenges, there is yet another dupe: Can we hold competitons?)
    – gnat
    Aug 16, 2019 at 11:26
  • 1
    There, now they're both on there.
    – Cerbrus
    Aug 16, 2019 at 11:28

2 Answers 2

8

This very likely not a good fit for Stack Overflow, but Code Review may be a good option, since they explicitly allow [interview-question] and [programming-challenge] questions.

To clarify, you should not post the interview/challenge question by itself and then self-answer with your solution. Rather, you should post a question that contains both the original challenge and your solution. Answers to your post will suggest improvements to your code. For example:

I found [this interview question] online asking readers to write a solution that can frob all the foos in a bar. I've written a solution, but I think it might be suboptimal.

I'm particularly concerned about high memory usage. I'm also pretty new to JavaScript so I'm concerned I might not be using the Array data structure idiomatically.

function frobAllFoos(bar) {
    ...
}

Their on-topic guide states:

Simply ask yourself the following questions. To be on-topic the answer must be "yes" to all questions:

  • Is code included directly in my question? (See Make sure you include your code in your question below.)
  • Am I an owner or maintainer of the code?
  • Is it actual code from a project rather than pseudo-code or example code?
  • Do I want the code to be good code? (i.e. not code-golfing, obfuscation, or similar)
  • To the best of my knowledge, does the code work as intended?
  • Do I want feedback about any or all facets of the code?

It seems like you meet all the criteria (but judge for yourself). See also CR's How do I ask a good question? page, which has norms about titles and content not common to other Stack Exchange sites.

1
  • So, I have asked the question on Code Review and have received a good response. [link](codereview.stackexchange.com/questions/92751/return- all-words-which-have-their-reverse-present-in-a-string) Wondering if the question would have got the same response if I had posted it on Stack Overflow. Jun 5, 2015 at 16:58
1

If I ignore the worries about it not being the most optimal and focus only on the bold part as being the question:

Is it okay to post material, such as a puzzle or a question, from another site on Stackoverflow so the answer/solution may be provided here?

A: Yes its fine, as long as you properly give credit and the site's licensing allows it. When in doubt, don't do it. You do have to replicate the relevant bits of the material here, a direct link to the original site in itself is not enough as that is subject to link rot. The full code answer would also have to be posted here and not on an external site.


But one can't ignore the fact that the "most optimal" worry apparently had to be added to the question, it implies a hidden agenda. That hidden agenda probably puts it at risk of being off-topic.

  • do you want to ask others to provide different solutions "for comparison"? That's not a question, that's just a code request.

  • do you want to ask if the solution you have is good? That's a code review.

  • I have the idea this is the winner: do you just want to post the solution to a puzzle to "help" others - and you're worrying if the solution is actually good?

You'd have to begin with asking yourself what the value of the solution is regardless of it being correct or incorrect, since specifically where a puzzle is concerned it is all about the process towards the solution and not the solution itself.

Imagine a Rubik's cube. When the cube is in its solution state, all squares on each sides with a matching color, the cube is pointless other than being a decorative piece. If you'd want to provide an answer about its true purpose, you'd have to be talking about the twisting and turning to get it to the solution, optionally in the least amount of time possible.

So what would the answer you would be writing about the programming puzzle be about? Only your code, or does it mention twisting and turning of the code to get it to that solution state? If only the code, my answer would be "No, not a valid question and answer".

Not the answer you're looking for? Browse other questions tagged .