Java Stack Easy
\nclass Solution {\n    public int numberOfBeams(String[] bank) {\n        int n = bank.length;\n        Stack<Integer> s = new Stack<>();\n        for(int i =0
```\nclass Solution {\n    public int numberOfBeams(String[] bank) {\n        int n = bank.length;\n        Stack<Integer> s = new Stack<>();\n        for(int i =0; i<n ;i++){\n            int x = one(bank[i]);\n            if(x != 0){\n                s.push(x);\n            }\n        }\n        \n        int ans = 0, p = 0;\n        if(!s.isEmpty()) p = s.pop();\n       while(!s.isEmpty()){\n           ans += s.peek()*p;\n           p = s.pop();\n       }   \n        return ans;\n    \n    }\n    public int one(String str){\n        int n = 0;\n        for(int i =0; i<str.length() ;i++){\n            if(str.charAt(i)==\'1\') n++;\n        }\n        return n;\n    }\n}\n```
['Stack', 'Java']