🪟 Windows TippsBitLocker stuck on Decrypting or Encrypting in Windows 11(17.09.2026 um 00:29 Uhr)
🕵️ SicherheitslückenCVE-2026-69110 | Microck opencode-studio up to 2.4.3 missing authentication(17.09.2026 um 03:21 Uhr)
🪟 Windows TippsBitLocker stuck on Decrypting or Encrypting in Windows 11(17.09.2026 um 00:29 Uhr)
🕵️ SicherheitslückenCVE-2026-69110 | Microck opencode-studio up to 2.4.3 missing authentication(17.09.2026 um 03:21 Uhr)
🔧 Programmierung 🕛 vor 1 Jahr 3 Min Lesezeit
0

1267. Count Servers that Communicate

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

1267. Count Servers that Communicate



Difficulty: Medium



Topics: Array, Depth-First Search, Breadth-First Search, Union Find, Matrix, Counting



You are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that cell there is a server and 0 means that it is no server. Two servers are said to communicate if they are on the same row or on the same column.



Return the number of servers that communicate with any other server.



Example 1:







  • Input: grid = [[1,0],[1,1]]


  • Output: 3


  • Explanation: All three servers can communicate with at least one other server.



Example 3:








CODE
<?php
/**
* @param Integer[][] $grid
* @return Integer
*/

function countServers($grid) {
...
...
...
/**
* go to ./solution.php
*/

}

// Test the function with the provided examples
$grid1 = [[1, 0], [0, 1]];
$grid2 = [[1, 0], [1, 1]];
$grid3 = [[1, 1, 0, 0], [0, 0, 1, 0], [0, 0, 1, 0], [0, 0, 0, 1]];

echo countServers($grid1) . "\n"; // Output: 0
echo countServers($grid2) . "\n"; // Output: 3
echo countServers($grid3) . "\n"; // Output: 4
?>









Explanation:





  1. Counting Servers in Rows and Columns:




    • We iterate over the grid and count how many servers (i.e., 1s) are in each row and each column. We store these counts in the rowCount and colCount arrays.




  2. Identifying Communicating Servers:




    • After counting, we iterate over each server (cell with value 1). A server can communicate with others if the count of servers in its row (rowCount[i] > 1) or the count of servers in its column (colCount[j] > 1) is greater than 1. We then increment the result counter for each communicating server.




  3. Output:




    • The function returns the total count of servers that can communicate with other servers.








Time Complexity:





  • O(m * n), where m is the number of rows and n is the number of columns. This is because we iterate through the grid twice: once to count servers in rows and columns, and once to check for communication.



This solution efficiently handles the problem within the given constraints.



Contact Links



If you found this series helpful, please consider giving the



If you want more helpful content like this, feel free to follow me:





Vollständiger Original-Artikel
Den kompletten Beitrag mit allen Details direkt auf dev.to lesen.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
2 Quellen
CVE-2026-92597 | Nodemailer up to 9.0.x Addressparser lib/addressparser input validation (EUVD-2026-81297)
1 Quelle
BitLocker stuck on Decrypting or Encrypting in Windows 11
1 Quelle
CVE-2026-92599 | hapijs joi up to 17.13.6/18.0.0-18.2.5 isoDate Joi.string.isoDate redos (EUVD-2026-81299)
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten 1267. Count Servers that Communicate

Thematisch verwandte Begriffe: 1267, Count, Servers, that · 6 Treffer

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...