aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-07-17 20:15:21 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-07-17 20:15:21 +0100
commit97f5fcd7d00bb5840bed749a0004610aab34707b (patch)
tree359363a0515695602890073525acfe2095cc63de
parentf7f106195a5caa905e73bef19119f5e59f4d3f2b (diff)
downloadalgorithms-97f5fcd7d00bb5840bed749a0004610aab34707b.tar.gz
algorithms-97f5fcd7d00bb5840bed749a0004610aab34707b.tar.bz2
algorithms-97f5fcd7d00bb5840bed749a0004610aab34707b.zip
Fix productexceptself
-rw-r--r--leetcode/solutions.org4
1 files changed, 3 insertions, 1 deletions
diff --git a/leetcode/solutions.org b/leetcode/solutions.org
index 9be16cc..340bc73 100644
--- a/leetcode/solutions.org
+++ b/leetcode/solutions.org
@@ -188,8 +188,10 @@ vector<int> productexceptself(vector<int> &nums)
out[i + 1] = out[i] * nums[i];
int postfix = 1;
for (int i = n - 1; i >= 0; --i)
+ {
out[i] *= postfix;
- postfix *= nums[i];
+ postfix *= nums[i];
+ }
return out;
}
#+end_src