Can anyone please help me, to figure out this issue ?
For this input = [[1,1],[2,2],[3,4],[4,5],[5,6],[7,7]]
My soln is showing right result on my system (on codeblocks), but when i tried running it here on leetcode its showing wrong ?
I tried, but unable to figure what exactly is happening ?
Same soln, but then why its showing right answer on my system but here wrong ?
class Solution
{
public:
bool checkStraightLine(vector<vector<int>>& coordinates)
{
bool status = true;
int n, ctr = 0, lhs, rhs;
n = coordinates[0].size();
if(2 < n)
{
for(ctr = 0; ctr < n - 1; ctr++)
{
lhs = (coordinates[0][n - 1] - coordinates[0][0])
* (coordinates[1][ctr] - coordinates[1][0]);
rhs = (coordinates[1][n - 1] - coordinates[1][0])
* (coordinates[0][ctr] - coordinates[0][0]);
if( lhs != rhs )
{
status = false; break;
}
}
}
return status;
}
};