How do I give access permission for specific node to anonymous User I have removed "Access Content " Permission from Anonymous user. Now want to display specific node to the anonymous user.

As this is for only 1 or 2 nodes, It's not a good idea to use a contributed module like https://www.drupal.org/project/access_by_entity. I am looking for a solution as a custom code only 

I have tried mymodule_node_access also but it's not working.
Give back the "Node access" permission (View published content) to Anonymous user and control the accesss with your custom module

use Drupal\Core\Access\AccessResult;
use Drupal\node\NodeInterface;

function MODULENAME_node_access(NodeInterface $node, $op, $account) {
  $allowed = [1,2];
  if ($op == "view" &amp;&amp; in_array($node-&gt;id(),$allowed)) {
    return AccessResult::allowed();
  }
  return AccessResult::forbidden();
}