Check if an array of posts has posts from a specific category

I have successfully returned the counts using the following code. Just in case someone may later view this question.

$count = 0;
$category = '45';
foreach ( $array as $post_id ) {
    if (in_category( $category, $post_id )) {
        $count++;
    }
}
echo $count;