Welcome to LeetCode Discuss.  Please read the FAQ to help yourself making the best use of Discuss.
Ask a Question
Back to Problem

Welcome to LeetCode Discuss.

This is a place to ask questions related to only OJ problems.

Please read the FAQ to help yourself making the best use of Discuss.

Do python in leetcode support numpy? Why I cannot import numpy as np? Always a compile error.

0 votes
12 views

the code is working fine at my machine, but get a compile error in leetcode

# Definition for a point

class Point:

def init(self, a=0, b=0):

self.x = a

self.y = b

import numpy as np class Solution: # @param points, a list of Points # @return an integer

def maxPoints(self, points):
    l = len(points)
    maxv = 0
    m = 0
    vx = []
    vy = []
    vz = []
    for i in range(l-1):
        for j in range(i+1,l):
            vx.append(points[i].x-points[j].x)
            vy.append(points[i].y-points[j].y)
            if points[i].x-points[j].x==0:
                vz.append(' ')
            else:
                vz.append((points[j].y*points[i].x-points[i].y*points[j].x)/(points[i].x-points[j].x))
            m = m+1
    for i in range(m-1):
        num = 1
        for j in range(i+1,m):
            if (np.mod(vx[j],vx[i])==np.mod(vy[j],vy[i])):
                if vz[i]==vz[j]:
                    num = num + 1
        if num > maxv:
            maxv = num
    maxv = (1+np.sqrt(1+8*maxv))/2
    return maxv
asked 2 days ago in Max Points on a Line by qiuyang (130 points)

1 Answer

0 votes

Import anything in python is forbidden in LeetCode.

We will consider import numpy later or not. However, we will update about it.

However, It would be better to use something else instead for now.

answered 2 days ago by Shangrila (25,720 points)

...