DivyaGodayal / CoderChef-Kitchen

The official repository for our programming kitchen which consists of 50+ delicious programming recipes having all the interesting ingredients ranging from dynamic programming, graph theory, linked lists and much more. All the articles contain beautiful images and some gif/video at times to help clear important concepts.
373 stars 82 forks source link

Rotate Array #94

Closed samhitharamaprasad closed 5 years ago

samhitharamaprasad commented 5 years ago

https://leetcode.com/problems/rotate-array/

There are various straightforward ways to solve this problem but while I came across quite a creative approach to solve it in O(1) extra space and O(n) time. The solution involves reversal of an array, which is shared in an article as one of the top 25 interview questions. Let me know what you think of it.

DivyaGodayal commented 5 years ago

@samhitharamaprasad The question looks good. I can see there is an existing solution on LeetCode for this, including the one you have mentioned, i.e. reversal of an array. If you can explain things in a better and more illustrative way then it's fine. Since our intention is to try an add value to the existing solutions out there.

samhitharamaprasad commented 5 years ago

@DivyaGodayal yes, I can. Would you like me to select a different question though? Also, do I have to come up with a new solution to my questions, something that does not already exist? Please give me some clarity about this.

edorado93 commented 5 years ago

Hi @samhitharamaprasad, the question is fine. You can go ahead with it. We usually attempt the problem ourselves first and try and come up with the most efficient solution(s) possible and we write about those in the article. Additionally, if we read an amazing approach/algorithm/implementation somewhere for the same question (when we're not satisfied with ours), we tend to add it as well to the article. The only differentiating factor is the way we tend to explain things in the articles with figures and code snippets etc.

samhitharamaprasad commented 5 years ago

@edorado93 great! Thanks

edorado93 commented 5 years ago

97