-
Notifications
You must be signed in to change notification settings - Fork 46
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
dhanuborse
wants to merge
148
commits into
saritapatel8770:revert-34-new-branch
Choose a base branch
from
dhanuborse:main
base: revert-34-new-branch
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Max_points_on_line/ #135
dhanuborse
wants to merge
148
commits into
saritapatel8770:revert-34-new-branch
from
dhanuborse:main
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Median Of two sorted arrays in cpp
…new-branch Revert "saritapatel8770#22 resolved - added solution of Sort the People problem"
Added 42. Trapping Rain Water in Java
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
Leetcode Solution added
Added solution of question 2415.(Reverse Odd Levels of Binary Tree)
…g-optimal-string-partition-js Added optimal string partition in JS
Added code for combination_sum_II
resolved saritapatel8770#22 - added the solution
Update longest_valid_parentheses.java
Create Number_of_Dice_Rolls_With_Target_Sum.cpp
Minimum_Operations_to_Reduce_X_to_Zero.java
Create Insert-Interval.java
Add files via upload
Create Maximum Sliding problem
Combination Sum II
Added solution to Minimum Operations to Reduce X to Zero in c++. Please review and let me know.
Running Sum of 1d Array
Two Sum IV - Input is a BST Solution Added in java language.
Median of Two Sorted Arrays
Added Solution based on saritapatel8770#68
added solution in java
…l-sarojwasti Insert Interval in Python
Leetcode 14 Days Study Plan (Day2 to Day5 Java Solutions Added)
Added Python code for Longest Valid Parentheses
trapping rain water
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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);
}