Skip to content

Commit 3ec4414

Browse files
authored
Update README.md
1 parent 1b1c275 commit 3ec4414

File tree

1 file changed

+1
-36
lines changed

1 file changed

+1
-36
lines changed

README.md

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,23 @@ Use a HashMap (m) to store the frequency of each number in the array.
3131
- - - - 3*n + 2 = 3*(n) + 2*(1) -> n+1 operations
3232
- Return Result :
3333
- - Return the total number of operations needed to make all numbers in the array divisible by 3.
34-
=======
35-
## Today's 03-01-24 [Problem Link](https://leetcode.com/problems/number-of-laser-beams-in-a-bank/description/?envType=daily-question&envId=2024-01-03)
36-
37-
# Intuition
38-
<!-- Describe your first thoughts on how to solve this problem. -->
39-
Basic multiplication.
40-
# Approach
41-
<!-- Describe your approach to solving the problem. -->
42-
- I kept track of number of '1' in a row
43-
- Now iterated over every row of array
44-
- - counted the number of '1' in current row
45-
- - number of beams will the product of current number of device and previous number of devices
46-
- - added the product to answer
47-
- - now, the current one will become the previous one to next row
48-
>>>>>>> 8326dfdfc4354991bd3c7f23df8fcaa854307652
4934
---
5035
Have a look at the code , still have any confusion then please let me know in the comments
5136
Keep Solving.:)
5237

5338
# Complexity
5439
- Time complexity : $$O(l)$$
5540
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
56-
<<<<<<< HEAD
5741

5842
- Space complexity : $$O(u)$$
5943

6044
$$l$$ : size of array
6145
$$u$$ : number of unique letters in array
62-
=======
63-
$$l$$ : length of array
64-
- Space complexity : $$O(1)$$
65-
>>>>>>> 8326dfdfc4354991bd3c7f23df8fcaa854307652
6646
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
6747

6848
# Code
6949
```
7050
class Solution {
71-
<<<<<<< HEAD
7251
public int minOperations(int[] nums) {
7352
boolean haveone = false;
7453
HashMap<Integer, Integer> m = new HashMap<>();
@@ -95,20 +74,6 @@ class Solution {
9574
}
9675
}
9776
return operations;
98-
=======
99-
public int numberOfBeams(String[] bank) {
100-
int jawab = 0; // to store answer
101-
int picheek = 0; // to store number of '1' in previous state
102-
103-
for( String r : bank){
104-
int ek = (int) r.chars().filter( g -> g == '1').count(); // counting the number of '1' in current row
105-
if( ek != 0){ // number of beams will the product of current number of device and previous number of devices
106-
jawab += picheek*ek; // adding the product to answer
107-
picheek = ek; // now, the current one will become the previous one to next row
108-
}
109-
}
110-
return jawab;
111-
>>>>>>> 8326dfdfc4354991bd3c7f23df8fcaa854307652
11277
}
11378
}
114-
```
79+
```

0 commit comments

Comments
 (0)