Оптимальное решение:
+ (int)maxProfit:(NSArray *)prices {
int maxProfit = 0;
int bestBuy = 0;
int bestSell = 0;
int currentBestBuy = 0;
for (int i= 1; i < prices.count; i++) {
int todayPrice = [prices[i] intValue];
int bestBuyPrice = [prices[currentBestBuy] intValue];
if (todayPrice < bestBuyPrice) {
currentBestBuy = i;
bestBuyPrice = todayPrice;
}
if (maxProfit < (todayPrice - bestBuyPrice)) {
bestSell = i;
bestBuy = currentBestBuy;
maxProfit = (todayPrice - bestBuyPrice);
}
}
NSLog(@"Buy Day : %d", bestBuy);
NSLog(@"Sell Day : %d", bestSell);
return maxProfit;
}
Я предложил бы читать этот поток с 2006 (На соединении разработчиков услуг Amazon Web). Кажется, что нет никакого легкого решения этого.
вы можете сделать это, используя dns webforwards и маскировку. просто перейдите на полный путь index.html
www.example.com переадресует на http://www.example.com.s3.amazonaws.com и убедитесь, что вы замаскировали вывод.
Да. Использование AWS Cloudfront позволяет назначить файл по умолчанию.