Does this code give a different output on your editor? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Does this code give a different output on your editor?

This is one of leetcode problems i solved and it worked perfectly here on sololearn and an online text editor i ran it on("jsbin"). But upon testing it on leetcode's editor, it kept on giving a different output. The code is supposed to take a specified portion of an array from it end and place it at the beginning(i.e rotate a portion). Example: input = func([1,2,3,4,5,6,7],3); output = [5,6,7,1,2,3,4]; But on leetcode, output was still [1,2,3,4,5,6,7]. I just need someone to help me run it on their text editor to know what the problem is. https://code.sololearn.com/ct5CI25CbA6T/?ref=app

19th Oct 2020, 5:43 AM
Infinite
Infinite - avatar
10 Answers
+ 1
output [ 5,6,7,1,2,3,4] [ 'c', 'd', 'a', 'b' ]
21st Oct 2020, 4:38 AM
Chris Coder
Chris Coder - avatar
+ 1
Chris C. Thanks. I really appreciate. I'm getting the same output but the solution keeps getting rejected.
21st Oct 2020, 12:24 PM
Infinite
Infinite - avatar
+ 1
Select JavaScript as your document type in the drop down menu.
21st Oct 2020, 12:34 PM
Chris Coder
Chris Coder - avatar
+ 1
leetcode output Finished in 88 ms [ 5, 6, 7, 1, 2, 3, 4 ] [ 'c', 'd', 'a', 'b' ]
21st Oct 2020, 12:37 PM
Chris Coder
Chris Coder - avatar
+ 1
Infinite yes I simply started a new leetcode playground and copied your text from codeplayground and pasted it to leetcode playground. Selected JavaScript and ran the code. It worked.
21st Oct 2020, 12:54 PM
Chris Coder
Chris Coder - avatar
0
Post the output you get as answers.
19th Oct 2020, 7:02 AM
Infinite
Infinite - avatar
0
Chris C. I did, i will try it again. Did you try it on yours?
21st Oct 2020, 12:40 PM
Infinite
Infinite - avatar
0
Chris C. Thanks very much. I guess the problem is from my device. This is actually the second time my solution is getting rejected.
21st Oct 2020, 1:01 PM
Infinite
Infinite - avatar
0
What do you mean by rejected? Is it throwing an error?
21st Oct 2020, 1:02 PM
Chris Coder
Chris Coder - avatar
0
Chris C. Not an error, it run's but gives a different output. https://www.sololearn.com/post/691237/?ref=app
21st Oct 2020, 1:07 PM
Infinite
Infinite - avatar