TGStat
TGStat
Type to search
Advanced channel search
  • flag English
    Site language
    flag Russian flag English flag Uzbek
  • Sign In
  • Catalog
    Channels and groups catalog Search for channels
    Add a channel/group
  • Ratings
    Rating of channels Rating of groups Posts rating
    Ratings of brands and people
  • Analytics
  • Search by posts
  • Telegram monitoring
NoorifyLabs

27 Jan, 11:30

Open in Telegram Share Report

Product of Array Except Self
Difficulty: Medium

Problem Statement:
You are given an integer array nums. Create and return a new array answer such that answer[i] is equal to the product of all the elements in nums except nums[i].

Requirements:
●The solution must run in O(n) time.
●You are not allowed to use division.
●The product of any prefix or suffix of the array is guaranteed to fit within a 32-bit integer.

Examples:

Input: nums = [1, 2, 3, 4]
Output: [24, 12, 8, 6]

Input: nums = [-1, 1, 0, -3, 3]
Output: [0, 0, 9, 0, 0]

Constraints:
2 ≤ nums.length ≤ 10⁵
-30 ≤ nums[i] ≤ 30

Can you solve it in O(n) time without using division?

46 0 0 6
Catalog
Channels and groups catalog Channels compilations Search for channels Add a channel/group
Ratings
Rating of Telegram channels Rating of Telegram groups Posts rating Ratings of brands and people
API
API statistics Search API of posts API Callback
Our channels
@TGStat @TGStat_Chat @telepulse @TGStatAPI
Read
Академия TGStat Telegram Research 2019 Telegram Research 2021 Telegram Research 2023
Contacts
Справочный центр Support Email Jobs
Miscellaneous
Terms and conditions Privacy policy Public offer
Our bots
@TGStat_Bot @SearcheeBot @TGAlertsBot @tg_analytics_bot @TGStatChatBot