zoukankan      html  css  js  c++  java
  • 查找表_leetcode149

    #coding=utf-8
    # 解题思路: 斜率查找表 20190302 找工作期间



    # Definition for a point.
    # class Point(object):
    # def __init__(self, a=0, b=0):
    # self.x = a
    # self.y = b

    class Solution(object):
    def maxPoints(self, points):
    """
    :type points: List[Point]
    :rtype: int
    """
    size = len(points)
    if size < 3:
    return size
    ans = 0
    for i in range(size):
    d = {'inf':0}
    samePoint = 1
    for j in range(size):
    if i == j:
    continue
    elif points[i].x == points[j].x and points[i].y != points[j].y:
    d['inf'] += 1
    elif points[i].x != points[j].x:
    k = 1.0 * (points[i].y - points[j].y) / (points[i].x - points[j].x)
    if k in d:
    d[k] += 1
    else:
    d[k] = 1
    else:
    samePoint += 1
    ans = max(ans,max(d.values()) + samePoint)
    return ans
  • 相关阅读:
    刷题(十五)
    Pycharm按装
    Jmeter
    内存泄露部分检测工具
    Failed to resolve
    图片显示方向不对怎么办
    ScaleType属性
    RobotFramework
    LoadRunner
    Appium
  • 原文地址:https://www.cnblogs.com/lux-ace/p/10546910.html
Copyright © 2011-2022 走看看