国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

[LintCode] Daily Temperatures

lemon / 337人閱讀

Problem

Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead.

For example, given the list temperatures = [73, 74, 75, 71, 69, 72, 76, 73], your output should be [1, 1, 4, 2, 1, 1, 0, 0].

Example

Input:
temperatures = [73, 74, 75, 71, 69, 72, 76, 73]
Output:
[1, 1, 4, 2, 1, 1, 0, 0]

Solution
public class Solution {
    /**
     * @param temperatures: a list of daily temperatures
     * @return: a list of how many days you would have to wait until a warmer temperature
     */
    public int[] dailyTemperatures(int[] input) {
        // for input[i], return the number of days in the future 
        // that have a higher temperature
        
        int record[] = new int[input.length];
        for (int i = 0; i < record.length; i++) {
            for (int j = i+1; j < record.length; j++) {
                if (input[j] > input[i]) {
                    record[i] = j-i;
                    break;
                }
            }
        }
        
        return record;
    }
}

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/71519.html

相關(guān)文章

  • LeetCode 739:每日溫度 Daily Temperatures

    摘要:提示氣溫列表長度的范圍是。第二次遍歷棧頂對應(yīng)索引的溫度索引出棧此時(shí)棧為空,。索引入棧,第三次遍歷棧頂對應(yīng)索引的溫度滿足要求當(dāng)前索引入棧。每個氣溫的值的均為華氏度,都是在范圍內(nèi)的整數(shù)。 題目: 根據(jù)每日 氣溫 列表,請重新生成一個列表,對應(yīng)位置的輸入是你需要再等待多久溫度才會升高超過該日的天數(shù)。如果之后都不會升高,請?jiān)谠撐恢糜?0 來代替。 例如,給定一個列表 temperatures ...

    zhkai 評論0 收藏0
  • [LeetCode] 739. Daily Temperatures

    Problem Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day f...

    dailybird 評論0 收藏0
  • 劍指offer/LintCode12_最小棧

    摘要:劍指最小棧聲明文章均為本人技術(shù)筆記,轉(zhuǎn)載請注明出處解題思路實(shí)現(xiàn)功能實(shí)現(xiàn)一個最小棧,要求操作均為復(fù)雜度,解題思路用棧存儲數(shù)據(jù)用最小棧存儲中最小元素,保證棧頂元素與棧頂元素同步,表示此時(shí)最小值將與此時(shí)最小值比較,將更小的一方壓棧,保證中棧頂始終 劍指offer/LintCode12_最小棧 聲明 文章均為本人技術(shù)筆記,轉(zhuǎn)載請注明出處https://segmentfault.com/u/yz...

    Betta 評論0 收藏0
  • 劍指offer/LintCode40_用兩個棧模擬隊(duì)列

    摘要:劍指用兩個棧模擬隊(duì)列聲明文章均為本人技術(shù)筆記,轉(zhuǎn)載請注明出處解題思路實(shí)現(xiàn)功能用兩個棧模擬實(shí)現(xiàn)一個隊(duì)列的,和操作解題思路假設(shè)有兩個棧隊(duì)列實(shí)現(xiàn)始終用入棧實(shí)現(xiàn)隊(duì)列和實(shí)現(xiàn)由于依次出棧并壓入中,恰好保證中順序與模擬隊(duì)列順序一致,始終保證棧頂元素為模擬 劍指offer/LintCode40_用兩個棧模擬隊(duì)列 聲明 文章均為本人技術(shù)筆記,轉(zhuǎn)載請注明出處https://segmentfault.com...

    bawn 評論0 收藏0
  • 劍指offer/LintCode494_用兩個隊(duì)列實(shí)現(xiàn)一個棧

    摘要:劍指用兩個隊(duì)列實(shí)現(xiàn)一個棧聲明文章均為本人技術(shù)筆記,轉(zhuǎn)載請注明出處解題思路實(shí)現(xiàn)功能用兩個隊(duì)列實(shí)現(xiàn)一個棧,實(shí)現(xiàn),,和方法解題思路假設(shè)有隊(duì)列和實(shí)現(xiàn)棧的操作實(shí)現(xiàn)棧操作始終用來入隊(duì)實(shí)現(xiàn)實(shí)現(xiàn)棧的方法模擬棧的過程中,保證兩個隊(duì)列中始終有一個隊(duì)列為空,另一 劍指offer/LintCode494_用兩個隊(duì)列實(shí)現(xiàn)一個棧 聲明 文章均為本人技術(shù)筆記,轉(zhuǎn)載請注明出處https://segmentfault....

    rose 評論0 收藏0

發(fā)表評論

0條評論

最新活動
閱讀需要支付1元查看
<