HTMLify
LeetCode - Number of Laser Beams in a Bank - C#
Views: 382 | Author: abh
public class Solution {
public int NumberOfBeams(string[] bank) {
int pre_lesers = 0;
int beams = 0;
foreach (string floor in bank){
int current_lesers = 0;
foreach (char c in floor){
if (c == '1')
current_lesers += 1;
}
if (current_lesers==0)
continue;
beams += pre_lesers * current_lesers;
pre_lesers = current_lesers;
}
return beams;
}
}
Comments

This is my first C# code
Reply(Mention)