Queen's Attack II Discussions | Algorithms | HackerRank
We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hint 1- Just check all obstacles that they are on one of four lines. Then you will have at maximun eight obstacles.
Hint 2 - then just calculate distance to obstacle or edge of the board.
public static boolean isPointOnLines(int xc, int yc, int xt, int yt) {
if (yt == yc && xt != xc) {
return true;
}
if (xt == xc && yt != yc) {
return true;
}
if ((xt - xc) == (yt - yc)) {
return true;
}
if ((xt - xc) == (yc - yt)) {
return true;
}
return false;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Queen's Attack II
You are viewing a single comment's thread. Return to all comments →
Hint 1- Just check all obstacles that they are on one of four lines. Then you will have at maximun eight obstacles. Hint 2 - then just calculate distance to obstacle or edge of the board.