GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Karteikarten

Product of Array Except Self - Leetcode

Suhas S Englisch 1 Karte

Karten in diesem Stapel (1)

  1. 1Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it without division and in O(n). For example, given [1,2,3,4], return [24,12,8,6].class Solution {
    public int[] productExceptSelf(int[] nums) {
    int n = nums.length;
    int[] prod = new int[n];
    int temp = 1;
    for(int i = 0; i=0 ; i--){
    prod[i] = prod[i] * temp;
    temp = temp * nums[i];
    }
    return prod;
    }
    }

Informationen

Beschreibung
Karteikarten am Product of Array Except Self - Leetcode, erstellt von Suhas S am 24/03/2018.
Erstellt von
Suhas S · Mär 2018
Aktualisiert
24 Mär 2018
Aufrufe
4
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck