¡GoConqr estrena diseño! Cuéntanos qué te parece.

Fichas

Product of Array Except Self - Leetcode

Suhas S Inglés 1 ficha

Fichas del conjunto (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;
    }
    }

Información

Descripción
Fichas sobre Product of Array Except Self - Leetcode, creado por Suhas S el 24/03/2018.
Creado por
Suhas S · mar 2018
Actualizado
24 mar 2018
Visitas
4
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?