GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/java/238_Product_of_Array_Except_Self.java at master · mridullpandey/leetcode Expand file tree/ Copy path238_Product_of_Array_Except_Self.javaMore file actions 18 lines (18 loc) · 463 Bytes / Copy path238_Product_of_Array_Except_Self.javaFile metadata and controls18 lines (18 loc) · 463 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 public class Solution { public int[] productExceptSelf(int[] nums) { int n = nums.length; int[] res = new int[n]; res[0] = 1; for (int i = 1; i < n; i++) { // left part res[i] = res[i - 1] * nums[i - 1]; } int right = 1; for (int i = n - 1; i >= 0; i--) { res[i] *= right; // right part right *= nums[i]; } return res; } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |