主頁 高登熱話 吃喝玩樂 科技消費 名人專訪 短片
現有會員可[按此]登入。未成為會員可[按此]註冊。
[公司模式 - 關]  [懷舊模式 - 開
[Youtube 預覽 - 關]  [大字型]  [小字型]

您現在聚腳在 學術台內。

【再負荊請罪】全新高登官方app HKG正式上架 會員永久免廣告
是咁的,2016年年尾,我因為忽略會員對手機程式o既需求,做o左一個不明智o既決定,加上一直未有好好回應會員平日訴求,最終令唔少會員不滿。事件並唔單單影響我,亦影響一直以來熱愛高登o既每一名網民,為此再向各位表示衷心歉意。:-(

或者有巴打會講,寫好隻app自然會有人回家。我唔否認自己曾經都抱過呢種僥倖心態,但沉思過後,我明白其實只係寫好一隻app並不足夠,要為高登會員做o既事情實在太多,包括提升網速同改善伺服器穩定、維護自由o既討論空間、鼓勵會員參與創作及討論等。因為,高登最珍貴o既係每一位會員,所以落足心力滿足會員訴求係高登o既首要任務。 ......
精選文章
DeerGamer
New App Android IOS
跳至第

發起人
[IT狗] Programming, Algorithm, Problem Solving 討論區 (2)
221 個回應
癲佬咩事

任何IT話題都歡迎 #hoho#


#good2#4    #bad#1  
標籤:
上post夠3個月自動沉底 :o)
https://forum.hkgolden.com/thread/7156163


臨訓推一推 #kill# #kill2#


739. Daily Temperatures https://leetcode.com/problems/daily-temperatures/

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 for which this is possible, put 0 instead.

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

#hoho#


752. Open the Lock https://leetcode.com/problems/open-the-lock/

You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rotate freely and wrap around: for example we can turn '9' to be '0', or '0' to be '9'. Each move consists of turning one wheel one slot.

The lock initially starts at '0000', a string representing the state of the 4 wheels.

You are given a list of deadends dead ends, meaning if the lock displays any of these codes, the wheels of the lock will stop turning and you will be unable to open it.

Given a target representing the value of the wheels that will unlock the lock, return the minimum total number of turns required to open the lock, or -1 if it is impossible.

Example 1:
Input: deadends = ["0201","0101","0102","1212","2002"], target = "0202"
Output: 6
Explanation:
A sequence of valid moves would be "0000" -> "1000" -> "1100" -> "1200" -> "1201" -> "1202" -> "0202".
Note that a sequence like "0000" -> "0001" -> "0002" -> "0102" -> "0202" would be invalid,
because the wheels of the lock become stuck after the display becomes the dead end "0102".


幾得意


BFS... basically. Each 4 digit number has 8 neighbours, except the dead ends which have none. Do a BFS from "0000" and check the depth of the target.


Details
Runtime: 36 ms, faster than 95.31% of C++ online submissions for Open the Lock.
Memory Usage: 10.4 MB, less than 100.00% of C++ online submissions for Open the Lock.


739. Daily Temperatures https://leetcode.com/problems/daily-temperatures/

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 for which this is possible, put 0 instead.

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

#hoho#


Use an ordered map from temperature to position and then scan the list backwards



There is a bug in above. [sosad] need to think a bit more.


There is a bug in above. [sosad] need to think a bit more.

I think I can use a Fenwick tree again for this one.


739. Daily Temperatures https://leetcode.com/problems/daily-temperatures/

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 for which this is possible, put 0 instead.

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

#hoho#


Sort of O(n).... Actually time complexity is O(n * log k) where k is the range of the temperature but k is constant.

Success
Details
Runtime: 188 ms, faster than 82.05% of C++ online submissions for Daily Temperatures.
Memory Usage: 13.9 MB, less than 100.00% of C++ online submissions for Daily Temperatures.


1375. Bulb Switcher III https://leetcode.com/problems/bulb-switcher-iii/
There is a room with n bulbs, numbered from 1 to n, arranged in a row from left to right. Initially, all the bulbs are turned off.

At moment k (for k from 0 to n - 1), we turn on the light[k] bulb. A bulb change color to blue only if it is on and all the previous bulbs (to the left) are turned on too.

Return the number of moments in which all turned on bulbs are blue.



Example 1:

https://assets.leetcode.com/uploads/2020/02/29/sample_2_1725.png


1375. Bulb Switcher III https://leetcode.com/problems/bulb-switcher-iii/
There is a room with n bulbs, numbered from 1 to n, arranged in a row from left to right. Initially, all the bulbs are turned off.

At moment k (for k from 0 to n - 1), we turn on the light[k] bulb. A bulb change color to blue only if it is on and all the previous bulbs (to the left) are turned on too.

Return the number of moments in which all turned on bulbs are blue.



Example 1:

https://assets.leetcode.com/uploads/2020/02/29/sample_2_1725.png


Should be easy. O(n) time algorithm possible.


1375. Bulb Switcher III https://leetcode.com/problems/bulb-switcher-iii/
There is a room with n bulbs, numbered from 1 to n, arranged in a row from left to right. Initially, all the bulbs are turned off.

At moment k (for k from 0 to n - 1), we turn on the light[k] bulb. A bulb change color to blue only if it is on and all the previous bulbs (to the left) are turned on too.

Return the number of moments in which all turned on bulbs are blue.



Example 1:

https://assets.leetcode.com/uploads/2020/02/29/sample_2_1725.png


Should be easy. O(n) time algorithm possible.


O(n) time and O(n) space.

Success
Details
Runtime: 80 ms, faster than 92.45% of C++ online submissions for Bulb Switcher III.
Memory Usage: 16 MB, less than 100.00% of C++ online submissions for Bulb Switcher III.


1375. Bulb Switcher III https://leetcode.com/problems/bulb-switcher-iii/
There is a room with n bulbs, numbered from 1 to n, arranged in a row from left to right. Initially, all the bulbs are turned off.

At moment k (for k from 0 to n - 1), we turn on the light[k] bulb. A bulb change color to blue only if it is on and all the previous bulbs (to the left) are turned on too.

Return the number of moments in which all turned on bulbs are blue.



Example 1:

https://assets.leetcode.com/uploads/2020/02/29/sample_2_1725.png


Should be easy. O(n) time algorithm possible.


O(n) time and O(n) space.

Success
Details
Runtime: 80 ms, faster than 92.45% of C++ online submissions for Bulb Switcher III.
Memory Usage: 16 MB, less than 100.00% of C++ online submissions for Bulb Switcher III.

有O(1) space :D


1375. Bulb Switcher III https://leetcode.com/problems/bulb-switcher-iii/
There is a room with n bulbs, numbered from 1 to n, arranged in a row from left to right. Initially, all the bulbs are turned off.

At moment k (for k from 0 to n - 1), we turn on the light[k] bulb. A bulb change color to blue only if it is on and all the previous bulbs (to the left) are turned on too.

Return the number of moments in which all turned on bulbs are blue.



Example 1:

https://assets.leetcode.com/uploads/2020/02/29/sample_2_1725.png


Should be easy. O(n) time algorithm possible.


O(n) time and O(n) space.

Success
Details
Runtime: 80 ms, faster than 92.45% of C++ online submissions for Bulb Switcher III.
Memory Usage: 16 MB, less than 100.00% of C++ online submissions for Bulb Switcher III.

有O(1) space :D

Let me see, comparing number of lights seen so far and running maximum?


1375. Bulb Switcher III https://leetcode.com/problems/bulb-switcher-iii/
There is a room with n bulbs, numbered from 1 to n, arranged in a row from left to right. Initially, all the bulbs are turned off.

At moment k (for k from 0 to n - 1), we turn on the light[k] bulb. A bulb change color to blue only if it is on and all the previous bulbs (to the left) are turned on too.

Return the number of moments in which all turned on bulbs are blue.



Example 1:

https://assets.leetcode.com/uploads/2020/02/29/sample_2_1725.png


Should be easy. O(n) time algorithm possible.


O(n) time and O(n) space.

Success
Details
Runtime: 80 ms, faster than 92.45% of C++ online submissions for Bulb Switcher III.
Memory Usage: 16 MB, less than 100.00% of C++ online submissions for Bulb Switcher III.

有O(1) space :D

Let me see, comparing number of lights seen so far and running maximum?


O(n) time and O(1) space. #hoho#

Success
Details
Runtime: 80 ms, faster than 92.45% of C++ online submissions for Bulb Switcher III.
Memory Usage: 12.9 MB, less than 100.00% of C++ online submissions for Bulb Switcher III.


739. Daily Temperatures https://leetcode.com/problems/daily-temperatures/

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 for which this is possible, put 0 instead.

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

#hoho#


Sort of O(n).... Actually time complexity is O(n * log k) where k is the range of the temperature but k is constant.

Success
Details
Runtime: 188 ms, faster than 82.05% of C++ online submissions for Daily Temperatures.
Memory Usage: 13.9 MB, less than 100.00% of C++ online submissions for Daily Temperatures.

你諗得太多#hehe# 向前行用stack搞得掂


842. Split Array into Fibonacci Sequencehttps://leetcode.com/problems/split-array-into-fibonacci-sequence/

There is a very elegant solution [shocking]


請教下各位 ......

小弟自學緊用 python 爬漫畫,但個網頁 D圖片似係加密咗

張圖條link .jpg 後面仲有串字 .webp?cid= .................

例:


請問要點先可以 download到 D圖片 #adore# #adore#

利申: 學緊用 requests[sosad]


請教下各位 ......

小弟自學緊用 python 爬漫畫,但個網頁 D圖片似係加密咗

張圖條link .jpg 後面仲有串字 .webp?cid= .................

例:


請問要點先可以 download到 D圖片 #adore# #adore#

利申: 學緊用 requests[sosad]

. split ('.jpg')[0] + '.jpg'
然後down落黎?


支持#good#
想學, 想轉行, 想做IT狗


請教下各位 ......

小弟自學緊用 python 爬漫畫,但個網頁 D圖片似係加密咗

張圖條link .jpg 後面仲有串字 .webp?cid= .................

例:


請問要點先可以 download到 D圖片 #adore# #adore#

利申: 學緊用 requests[sosad]

開browser developer mode開住個network睇佢點call你照住call咪得[sosad]
不過有d網做得好會係header做d手腳 咁就冇得就咁call 條api


支持#good#
想學, 想轉行, 想做IT狗

有冇底先[sosad]


支持#good#
想學, 想轉行, 想做IT狗

有冇底先[sosad]


無, 自學緊O:-)bg


怕問啲問題太低能
睇你地UP


支持#good#
想學, 想轉行, 想做IT狗

有冇底先[sosad]


無, 自學緊O:-)bg

學緊咩 [bouncy]


支持#good#
想學, 想轉行, 想做IT狗

有冇底先[sosad]


無, 自學緊O:-)bg

學緊咩 [bouncy]

javascript:D


跳至第



  快速回覆 - 輸入以下項目

本討論區現只接受會員張貼文章,本站會員請先登入。非會員人仕,您可以按此加入為新會員,費用全免,並可享用其他會員服務。


上次光臨時間: 12/8/2022 10:05
今天貼文總數: 475 | 累積文章數目: 7,038,149

聯絡我們 | 服務條款 | 私隱政策 | 廣告查詢 | 職位空缺
Copyright © 2022 HKGolden.com. All Rights Reserved.