Skip to content

Max_points_on_line/ #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 148 commits into
base: revert-34-new-branch
Choose a base branch
from

Conversation

dhanuborse
Copy link

var maxPoints = function(points) {
if (points.length <2|| points == null) return points.length;
let max = 2;
for (let i=0;i<points.length;i++) {
let [p1x, p1y] = points[i];
let samePoint = 1, map = {'base':0}; // to avoid when map = {}, the max value is -Infinity
for (let j=i+1;j<points.length;j++) {
if (points[i][0] == points[j][0] && points[i][1] == points[j][1]) {
samePoint++;
} else {
let [p2x, p2y] = points[j];
let slope = 1000000.0 * (p2y - p1y)/(p2x - p1x);
if (!Number.isFinite(slope)) slope = "v";
else if (Number.isNaN(slope)) slope = "h";
map[slope] = map[slope]+1||1;
}
}
max = Math.max(Math.max(...Object.values(map))+samePoint, max);
}

harmanjit356 and others added 30 commits October 2, 2022 23:59
…new-branch

Revert "saritapatel8770#22 resolved - added solution of Sort the People problem"
Create Median of Two Sorted ArmedianOfSortedArrays.cpp
I have added the code for Surrounded region probelm.
Create_Surrounded_Regions_Leetcode.cpp
…sitive

Added java solution for leetcode problem of first missing positive.
I have added the code for Word Break II Leetcode problem. 
Problem link-https://leetcode.com/problems/word-break-ii/
Kindly merge my pull request.
I have added the code for https://leetcode.com/problems/lru-cache/ problem. kindly merge my PR.
The best solution for "Longest Valid Parenthess" without any extra spaces in this approach
Create Reverse Odd Levels of Binary Tree in easiest way
Added solution of question 2415.(Reverse Odd Levels of Binary Tree)
…g-optimal-string-partition-js

Added optimal string partition in JS
Update longest_valid_parentheses.java
Create Number_of_Dice_Rolls_With_Target_Sum.cpp
Dhanshriborse and others added 30 commits October 6, 2022 15:35
Minimum_Operations_to_Reduce_X_to_Zero.java
Added solution to Minimum Operations to Reduce X to Zero in c++. Please review and let me know.
Two Sum IV - Input is a BST Solution Added in java language.
Leetcode 14 Days Study Plan (Day2 to Day5 Java Solutions Added)
Added Python code for Longest Valid Parentheses
Create Delete-Operation-for-Two-Strings.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.