LeetCode #238. Product of Array Except Self
使用此方式來解 Leetcode #238
但也無法完全搞懂 ~ 數學跟英文(題目) Orz....
public int[] ProductExceptSelf(int[] nums)
{
int[] result = new int[nums.Length];
int right = 1;
result[0] = 1;
for (int i = 1; i < nums.Length; i++)
{
result[i] = result[i - 1] * nums[i - 1];
}
for (int i = nums.Length - 1; i >= 0; i--)
{
result[i] = result[i] * right;
right = right * nums[i];
}
return result;
}
本頁面為一點點累積學習寫程式之路。
許多資訊不是正確、或只是自己看的懂得。
如果不小心點進來誤導了您,還真的不好意思。