Hi Guys, Today is 3 January 2024 and below is the solution for problem of the day So, the question we have is Number of Laser Beams in a Bank . In this we have to find total number of lasers. So just imagine it as we have to find number of lines connecting the dots. so if there are 2 dots. we will have one line, if we have 3 dots we will get 3 lines, and so on... Now relate the above provided example, let's relate this to our problem statement. We have 4 walls, first wall has 3 lasers, second wall has 0 lasers, third wall got 2 lasers and last wall has 1 laser. So as i suggested we need to connect dots so make sure to only join adjacent dots. So lasers from 1 and 3 wall will connect to each other (6 lasers) and wall 3 and 4 will connect to each other (2 lasers). So total of 8 lasers, which is the required output anyways. class Solution : def numberOfBeams ( self , bank : List[ str ]) -> int : val = 0 # Initialize a variable `val` to store th...
Comments
Post a Comment