Maximum Product Subarray,maximumsubarray
原題連結: https://oj.leetcode.com/problems/maximum-product-subarray/
這道題跟Maximum Subarray模型上和思路上都比較類似,還是用一維動態規劃中的“局部最優和全域最優法”。這裡的區別是維護一個局部最優不足以求得後面的全域最優,這是由於乘法的性質不像加法那樣,累加結果只要是正的一定是遞增,乘法中有可能現在看起來小的一個負數,後面跟另一個負數相乘就會得到最大的乘積。不過事實上也沒有麻煩很多,我們只需要在維護一個局部最大的同時,在維護一個局部最小,這樣如果下一個元素遇到負數時,就有可能與這個最小相乘得到當前最大的乘積和,這也是利用乘法的性質得到的。代碼如下:
public int maxProduct(int[] A) { if(A==null || A.length==0) return 0; if(A.length == 1) return A[0]; int max_local = A[0]; int min_local = A[0]; int global = A[0]; for(int i=1;i<A.length;i++) { int max_copy = max_local; max_local = Math.max(Math.max(A[i]*max_local, A[i]), A[i]*min_local); min_local = Math.min(Math.min(A[i]*max_copy, A[i]), A[i]*min_local); global = Math.max(global, max_local); } return global;}這道題是一道很不錯的面試題目,因為Maximum Subarray這道題過於常見了,所以可能大部分人都做過,這道題模型類似,但是又有一些新的考點,而且總體還是比較簡單,無論是思路上還是實現上,又能考察動態規劃,個人還是比較喜歡的哈。
Product of dimensions is greater than maximum integer怎解決
不知道你這個是在什麼情況下出現的。字面意思是“產品的尺寸超過最大整數。”
開啟憤怒的小鳥出現texture is too large:2048x2048,maximum supported size 1024x1024怎解決?
件
調整width = ?height = ?
就可以
用滑鼠直接拖也可以啊!
product = "Angry Birds"
publisher = "Rovio"
name = "Angry Birds"
width = 1024
height = 600
orientation = 0
datapath = "data"
imagePath = "images/pc_build"
fontPath = "fonts/pc_build"
audioPath = "audio"
localizationPath = "localization"
levelPath = "levels"
scriptPath = "scripts"
deviceModel = "windows"
fullscreen = false
showCursor = false