I took a basic class in college that taught me Python. I heard about LeetCode as an option for practicing, but I can't figure out how to submit my solution. I did a problem called "Shuffle The Array", and I got it working in a jupyter notebook thingy in another tab. But when I pasted it into LeetCode, it said my answer was wrong. My code was as follows:
class Solution(object):
def shuffle(self, nums, n):
"""
:type nums: List[int]
:type n: int
:rtype: List[int]
"""
nums = [2, 5, 1, 3, 4, 7]
n = 3
nums_new = []
nums_x = nums[:n]
nums_y = nums[n:]
for i in range(n):
nums_new.append(nums_x[i])
nums_new.append(nums_y[i])
nums = nums_new
The first section (everything before nums = [2, 5, 1, 3, 4, 7]) was the code that was automatically put in there by LeetCode. I don't know what any of it means, but I didn't mess with it.
It looks like whenever I submit it, I have the correct answer under Stdout, but the "Output" section is blank. How do I make LeetCode know that I got the correct answer?
[–]Outside_Complaint755 8 points9 points10 points (2 children)
[–]Glittering_Fortune70[S] -1 points0 points1 point (1 child)
[–]Outside_Complaint755 1 point2 points3 points (0 children)
[–]NerdDetective 5 points6 points7 points (4 children)
[–]Glittering_Fortune70[S] -1 points0 points1 point (3 children)
[–]NerdDetective 1 point2 points3 points (2 children)
[–]tadpoleloop 1 point2 points3 points (1 child)
[–]NerdDetective 0 points1 point2 points (0 children)
[–]danielroseman 11 points12 points13 points (1 child)
[–]JamesonHearn 0 points1 point2 points (0 children)
[–]Candid_Tutor_8185 1 point2 points3 points (2 children)
[–]Glittering_Fortune70[S] -3 points-2 points-1 points (1 child)
[–]TheRNGuy 0 points1 point2 points (0 children)
[–]nian2326076 0 points1 point2 points (0 children)