锘??xml version="1.0" encoding="utf-8" standalone="yes"?>成人精品一区二区久久,久久天天躁狠狠躁夜夜2020一 ,观看 国产综合久久久久鬼色 欧美 亚洲 一区二区 http://www.shnenglu.com/Uriel/articles/230243.htmlUrielUrielSat, 30 Dec 2023 13:21:00 GMThttp://www.shnenglu.com/Uriel/articles/230243.htmlhttp://www.shnenglu.com/Uriel/comments/230243.htmlhttp://www.shnenglu.com/Uriel/articles/230243.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230243.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230243.html
 1 #1897
 2 #Runtime: 67 ms (Beats 16.67%)
 3 #Memory: 13.6 MB (Beats 83.33%)
 4 
 5 class Solution(object):
 6     def makeEqual(self, words):
 7         """
 8         :type words: List[str]
 9         :rtype: bool
10         """
11         total = ''.join(words)
12         chars = set(total)
13         for ch in chars:
14             if total.count(ch) % len(words) != 0:
15                 return False
16         return True


Uriel 2023-12-30 21:21 鍙戣〃璇勮
]]>
[LeetCode]1758. Minimum Changes To Make Alternating Binary String (Easy) Python-2023.12.24http://www.shnenglu.com/Uriel/articles/230238.htmlUrielUrielSun, 24 Dec 2023 10:27:00 GMThttp://www.shnenglu.com/Uriel/articles/230238.htmlhttp://www.shnenglu.com/Uriel/comments/230238.htmlhttp://www.shnenglu.com/Uriel/articles/230238.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230238.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230238.html

#1758
#
Runtime: 25 ms (Beats 79.41%)
#
Memory: 13.4 MB (Beats 88.24)

class Solution(object):
    def minOperations(self, s):
        """
        :type s: str
        :rtype: int
        
"""
        ans1, ans2 = 0, 0
        for i in xrange(0, len(s)):
            if i % 2:
                if s[i] == '0':
                    ans1 += 1
                else:
                    ans2 += 1
            else:
                if s[i] == '1':
                    ans1 += 1
                else:
                    ans2 += 1
        return min(ans1, ans2)


Uriel 2023-12-24 18:27 鍙戣〃璇勮
]]>
[LeetCode]1496. Path Crossing (Easy) Python-2023.12.23http://www.shnenglu.com/Uriel/articles/230237.htmlUrielUrielSat, 23 Dec 2023 13:51:00 GMThttp://www.shnenglu.com/Uriel/articles/230237.htmlhttp://www.shnenglu.com/Uriel/comments/230237.htmlhttp://www.shnenglu.com/Uriel/articles/230237.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230237.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230237.html

 1 #1496
 2 #Runtime: 16 ms (Beats 59.29%)
 3 #Memory: 13.5 MB (Beats 76.11%)
 4 
 5 class Solution(object):
 6     def isPathCrossing(self, path):
 7         """
 8         :type path: str
 9         :rtype: bool
10         """
11         x, y = 0, 0
12         cor = {(x, y)}
13         for ch in path:
14             if ch == 'N':
15                 y += 1      
16             elif ch == 'S':
17                 y -= 1
18             elif ch == 'E':
19                 x += 1
20             else:
21                 x -= 1
22             if (x, y) in cor:
23                 return True
24             cor.add((x, y))
25         return False


Uriel 2023-12-23 21:51 鍙戣〃璇勮
]]>
[LeetCode]1422. Maximum Score After Splitting a String (Easy) Python-2023.13.22http://www.shnenglu.com/Uriel/articles/230236.htmlUrielUrielFri, 22 Dec 2023 08:35:00 GMThttp://www.shnenglu.com/Uriel/articles/230236.htmlhttp://www.shnenglu.com/Uriel/comments/230236.htmlhttp://www.shnenglu.com/Uriel/articles/230236.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230236.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230236.html


 1 #1422
 2 #Runtime: 13 ms (Beats 90.28%)
 3 #Memory: 13.3 MB (Beats 56.94%)
 4 
 5 class Solution(object):
 6     def maxScore(self, s):
 7         """
 8         :type s: str
 9         :rtype: int
10         """
11         ones = s[1:].count('1')
12         if s[0] == '0':
13             zeros = 1
14         else:
15             zeros = 0
16         ans = ones + zeros
17         for i in xrange(1, len(s) - 1):
18             if s[i] == '0':
19                 zeros += 1
20             else:
21                 ones -= 1
22             ans = max(ans, ones + zeros)
23         return ans


Uriel 2023-12-22 16:35 鍙戣〃璇勮
]]>
[LeetCode]1582. Special Positions in a Binary Matrix (Easy) Python-2023.12.13http://www.shnenglu.com/Uriel/articles/230226.htmlUrielUrielWed, 13 Dec 2023 11:24:00 GMThttp://www.shnenglu.com/Uriel/articles/230226.htmlhttp://www.shnenglu.com/Uriel/comments/230226.htmlhttp://www.shnenglu.com/Uriel/articles/230226.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230226.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230226.html

 1 #1582
 2 #Runtime: 121 ms (Beats 70.97%)
 3 #Memory: 13.6 MB (Beats 35.48%)
 4 
 5 class Solution(object):
 6     def numSpecial(self, mat):
 7         """
 8         :type mat: List[List[int]]
 9         :rtype: int
10         """
11         ans = 0
12         for i in xrange(len(mat)):
13             if mat[i].count(1) == 1:
14                 x = mat[i].index(1)
15                 col = [r[x] for r in mat]
16                 if col.count(1) == 1:
17                     ans += 1
18         return ans


Uriel 2023-12-13 19:24 鍙戣〃璇勮
]]>
[LeetCode]1903. Largest Odd Number in String (Easy) Python-2023.12.07http://www.shnenglu.com/Uriel/articles/230224.htmlUrielUrielFri, 08 Dec 2023 16:16:00 GMThttp://www.shnenglu.com/Uriel/articles/230224.htmlhttp://www.shnenglu.com/Uriel/comments/230224.htmlhttp://www.shnenglu.com/Uriel/articles/230224.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230224.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230224.html

 1 #1903
 2 #Runtime: 27 ms (Beats 98.59%)
 3 #Memory: 15.3 MB (Beats 81.69%)
 4 
 5 class Solution(object):
 6     def largestOddNumber(self, num):
 7         """
 8         :type num: str
 9         :rtype: str
10         """
11         p = -1
12         for i in xrange(len(num) - 1, -1, -1):
13             if (ord(num[i]) - ord('0')) % 2:
14                 p = i
15                 break
16         return num[0:p+1]
17                     


Uriel 2023-12-09 00:16 鍙戣〃璇勮
]]>
[LeetCode]2264. Largest 3-Same-Digit Number in String (Easy) Python-2023.12.04http://www.shnenglu.com/Uriel/articles/230219.htmlUrielUrielMon, 04 Dec 2023 10:51:00 GMThttp://www.shnenglu.com/Uriel/articles/230219.htmlhttp://www.shnenglu.com/Uriel/comments/230219.htmlhttp://www.shnenglu.com/Uriel/articles/230219.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230219.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230219.html
 1 #2264
 2 #Runtime: 17 ms (Beats 71.79%)
 3 #Memory: 13.4 MB (Beats 46.15%)
 4 
 5 class Solution(object):
 6     def largestGoodInteger(self, num):
 7         """
 8         :type num: str
 9         :rtype: str
10         """
11         x = '/'
12         t = 1
13         for i in xrange(1, len(num)):
14             if num[i] == num[i - 1]:
15                 t += 1
16                 if t >= 3:
17                     x = max(x, num[i])
18                     print(x)
19             else:
20                 t = 1
21         if x >= '0':
22             return x * 3
23         return ""


Uriel 2023-12-04 18:51 鍙戣〃璇勮
]]>
[LeetCode]1160. Find Words That Can Be Formed by Characters (Easy) Python-2023.12.02http://www.shnenglu.com/Uriel/articles/230211.htmlUrielUrielSat, 02 Dec 2023 04:19:00 GMThttp://www.shnenglu.com/Uriel/articles/230211.htmlhttp://www.shnenglu.com/Uriel/comments/230211.htmlhttp://www.shnenglu.com/Uriel/articles/230211.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230211.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230211.html
 1 #1160
 2 #Runtime: 71 ms (Beats 71.98%)
 3 #Memory: 14.4 MB (Beats 7.69%)
 4 
 5 class Solution(object):
 6     def countCharacters(self, words, chars):
 7         """
 8         :type words: List[str]
 9         :type chars: str
10         :rtype: int
11         """
12         ans = ''
13         for w in words:
14             for ch in w:
15                 if chars.count(ch) < w.count(ch):
16                     break
17             else:
18                 ans += w
19         return len(ans)


Uriel 2023-12-02 12:19 鍙戣〃璇勮
]]>
[LeetCode]1356. Sort Integers by The Number of 1 Bits (Easy) Python-2023.10.30http://www.shnenglu.com/Uriel/articles/230163.htmlUrielUrielTue, 31 Oct 2023 09:40:00 GMThttp://www.shnenglu.com/Uriel/articles/230163.htmlhttp://www.shnenglu.com/Uriel/comments/230163.htmlhttp://www.shnenglu.com/Uriel/articles/230163.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230163.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230163.html
 1 #1356
 2 #Runtime: 38 ms (Beats 86.93%)
 3 #Memory: 13.4 MB (Beats 63.83%)
 4 
 5 class Solution(object):
 6     def sortByBits(self, arr):
 7         """
 8         :type arr: List[int]
 9         :rtype: List[int]
10         """
11         arr.sort(key=lambda x: (bin(x).count("1"), x))
12         return arr


Uriel 2023-10-31 17:40 鍙戣〃璇勮
]]>
[LeetCode]2433. Find The Original Array of Prefix Xor (Medium) Python-2023.10.31http://www.shnenglu.com/Uriel/articles/230161.htmlUrielUrielTue, 31 Oct 2023 09:17:00 GMThttp://www.shnenglu.com/Uriel/articles/230161.htmlhttp://www.shnenglu.com/Uriel/comments/230161.htmlhttp://www.shnenglu.com/Uriel/articles/230161.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230161.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230161.html
 1 #2433
 2 #Runtime: 621 ms (Beats 43.23%)
 3 #Memory: 33.2 MB (Beats 7.74%)
 4 
 5 class Solution(object):
 6     def findArray(self, pref):
 7         """
 8         :type pref: List[int]
 9         :rtype: List[int]
10         """
11         ans = [pref[0]]
12         for i in xrange(1, len(pref)):
13             ans.append(pref[i] ^ pref[i - 1])
14         return ans


Uriel 2023-10-31 17:17 鍙戣〃璇勮
]]>
[LeetCode]342. Power of Four (Easy) Python-2023.10.23http://www.shnenglu.com/Uriel/articles/230154.htmlUrielUrielMon, 23 Oct 2023 06:00:00 GMThttp://www.shnenglu.com/Uriel/articles/230154.htmlhttp://www.shnenglu.com/Uriel/comments/230154.htmlhttp://www.shnenglu.com/Uriel/articles/230154.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230154.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230154.html
鍐欐硶涓

 1 #342
 2 #Runtime: 16 ms (Beats 49.50%)
 3 #Memory: 13.4 MB (Beats 12.41%)
 4 
 5 class Solution(object):
 6     def isPowerOfFour(self, n):
 7         """
 8         :type n: int
 9         :rtype: bool
10         """
11         return n > 0 and math.ceil(log10(n) / log10(4)) == int(log10(n) / log10(4))

鍐欐硶浜?br />
 1 #342
 2 #Runtime: 14 ms (Beats 68.30%)
 3 #Memory: 13.1 MB (Beats 88.85%)
 4 
 5 class Solution(object):
 6     def isPowerOfFour(self, n):
 7         """
 8         :type n: int
 9         :rtype: bool
10         """
11         if n <= 0:
12             return False
13         while n > 1:
14             if n % 4 != 0:
15                 return False
16             n = n // 4
17         return True


Uriel 2023-10-23 14:00 鍙戣〃璇勮
]]>
[LeetCode]1512. Number of Good Pairs (Easy) Python-2023.10.03http://www.shnenglu.com/Uriel/articles/230127.htmlUrielUrielTue, 03 Oct 2023 08:45:00 GMThttp://www.shnenglu.com/Uriel/articles/230127.htmlhttp://www.shnenglu.com/Uriel/comments/230127.htmlhttp://www.shnenglu.com/Uriel/articles/230127.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230127.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230127.html
 1 #1512
 2 #Runtime: 21 ms (Beats 23.47%)
 3 #Memory: 13.3 MB (Beats 40.52%)
 4 
 5 class Solution(object):
 6     def numIdenticalPairs(self, nums):
 7         """
 8         :type nums: List[int]
 9         :rtype: int
10         """
11         return sum(i * (i - 1) // 2 for i in Counter(nums).values())


Uriel 2023-10-03 16:45 鍙戣〃璇勮
]]>
[LeetCode]896. Monotonic Array (Easy) Python-2023.09.29http://www.shnenglu.com/Uriel/articles/230115.htmlUrielUrielFri, 29 Sep 2023 10:48:00 GMThttp://www.shnenglu.com/Uriel/articles/230115.htmlhttp://www.shnenglu.com/Uriel/comments/230115.htmlhttp://www.shnenglu.com/Uriel/articles/230115.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230115.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230115.html

 1 #896
 2 #Runtime: 777 ms (Beats 50.28%)
 3 #Memory: 23.3 MB (Beats 100%)
 4 
 5 class Solution(object):
 6     def isMonotonic(self, nums):
 7         """
 8         :type nums: List[int]
 9         :rtype: bool
10         """
11         if len(nums) == 1:
12             return True
13         i = 0
14         while i < len(nums) - 1 and nums[i] == nums[i + 1]:
15             i += 1
16         if i < len(nums) - 1:
17             if nums[i] < nums[i + 1]:
18                 while i < len(nums) - 1:
19                     if nums[i] > nums[i + 1]:
20                         return False
21                     i += 1
22             else:
23                 while i < len(nums) - 1:
24                     if nums[i] < nums[i + 1]:
25                         return False
26                     i += 1
27         return True


Uriel 2023-09-29 18:48 鍙戣〃璇勮
]]>
[LeetCode]392. Is Subsequence (Easy) Python-2021.02.01/2023.09.22http://www.shnenglu.com/Uriel/articles/230097.htmlUrielUrielFri, 22 Sep 2023 05:38:00 GMThttp://www.shnenglu.com/Uriel/articles/230097.htmlhttp://www.shnenglu.com/Uriel/comments/230097.htmlhttp://www.shnenglu.com/Uriel/articles/230097.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230097.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230097.html
 1 #392
 2 #Runtime: 8 ms (Beats 94.61%)
 3 #Memory: 13.3 MB (Beats 96%)
 4 
 5 class Solution(object):
 6     def isSubsequence(self, s, t):
 7         """
 8         :type s: str
 9         :type t: str
10         :rtype: bool
11         """
12         p = 0
13         for ch in s:
14             while p < len(t) and t[p] != ch:
15                 p += 1
16             if p >= len(t):
17                 return False
18             if t[p] == ch:
19                 p += 1
20         return True


Uriel 2023-09-22 13:38 鍙戣〃璇勮
]]>
[LeetCode]118. Pascal's Triangle (Easy) C++/Python-2014.01.05/2023.09.08http://www.shnenglu.com/Uriel/articles/230070.htmlUrielUrielFri, 08 Sep 2023 06:12:00 GMThttp://www.shnenglu.com/Uriel/articles/230070.htmlhttp://www.shnenglu.com/Uriel/comments/230070.htmlhttp://www.shnenglu.com/Uriel/articles/230070.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230070.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230070.html

python鐗?br />
 1 #118
 2 #Runtime: 7 ms (Beats 99.45%)
 3 #Memory: 13.3 MB (Beats 21.94%)
 4 
 5 class Solution(object):
 6     def generate(self, numRows):
 7         """
 8         :type numRows: int
 9         :rtype: List[List[int]]
10         """
11         ans = [[1]]
12         for i in range(1, numRows):
13             t = [1]
14             for j in range(len(ans[i - 1]) - 1):
15                 t.append(ans[i - 1][j] + ans[i - 1][j + 1])
16             t.append(1)
17             ans.append(t)
18         return ans

C++鐗?br />
 1 //118
 2 //Runtime: 12 ms (Beats 11.67%)
 3 
 4 
 5 class Solution {
 6 public:
 7     vector<vector<int> > generate(int numRows) {
 8         int dp[2][10010];
 9         vector<vector<int> > res;
10         for(int i = 1; i <= numRows; ++i) {
11             vector<int> tp;
12             for(int j = 1; j <= i; ++j) {
13                 if(j == 1 || j == i) dp[i & 1][j] = 1;
14                 else
15                     dp[i & 1][j] = dp[(i - 1) & 1][j - 1] + dp[(i - 1) & 1][j];
16                 tp.push_back(dp[i & 1][j]);
17             }
18             res.push_back(tp);
19         }
20         return res;
21     }
22 };


Uriel 2023-09-08 14:12 鍙戣〃璇勮
]]>
[LeetCode]168. Excel Sheet Column Title (Easy) Python-2021.01.28/2023.08.22http://www.shnenglu.com/Uriel/articles/230021.htmlUrielUrielTue, 22 Aug 2023 07:39:00 GMThttp://www.shnenglu.com/Uriel/articles/230021.htmlhttp://www.shnenglu.com/Uriel/comments/230021.htmlhttp://www.shnenglu.com/Uriel/articles/230021.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/230021.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/230021.html31 - 1錛岃緭鍑哄搴旂殑excel鐨勮埅鏍囷紙A~Z瀛楁瘝琛ㄧず鐨?6榪涘埗錛?br />
鍐欐硶涓錛氱敤list瀛楢~Z鎵懼搴?br />
 1 #168
 2 #Runtime: 24 ms (Beats 5.91%)
 3 #Memory: 13.4 MB (Beats 24.19%)
 4 
 5 class Solution(object):
 6     def convertToTitle(self, n):
 7         """
 8         :type n: int
 9         :rtype: str
10         """
11         s = ""
12         lst = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
13         while n > 0:
14             t = n % 26
15             if t == 0:
16                 t = 26
17             s = s + lst[t - 1]
18             n = (n - 1) // 26
19             #print(n)
20         return s[::-1]

鍐欐硶浜岋細(xì)鐢╬ython鑷甫鍑芥暟chr

 1 #168
 2 #Runtime: 11 ms (Beats 82.44%)
 3 #Memory: 13.2 MB (Beats 84.59%)
 4 
 5 class Solution(object):
 6     def convertToTitle(self, columnNumber):
 7         """
 8         :type columnNumber: int
 9         :rtype: str
10         """
11         s = ""
12         while columnNumber > 0:
13             t = (columnNumber - 1) % 26
14             s = s + chr(t + 65)
15             columnNumber = (columnNumber - 1) // 26
16         return s[::-1]


Uriel 2023-08-22 15:39 鍙戣〃璇勮
]]>
[LeetCode]1732. Find the Highest Altitude (Easy) Python-2023.06.19http://www.shnenglu.com/Uriel/articles/229936.htmlUrielUrielMon, 19 Jun 2023 08:27:00 GMThttp://www.shnenglu.com/Uriel/articles/229936.htmlhttp://www.shnenglu.com/Uriel/comments/229936.htmlhttp://www.shnenglu.com/Uriel/articles/229936.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229936.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229936.html

 1 #1732
 2 #Runtime: 26 ms (Beats 22.90%)
 3 #Memory: 13.3 MB (Beats 78.32%)
 4 
 5 class Solution(object):
 6     def largestAltitude(self, gain):
 7         """
 8         :type gain: List[int]
 9         :rtype: int
10         """
11         ans = 0
12         for i in range(0, len(gain)):
13             if i > 0:
14                 gain[i] = gain[i - 1] + gain[i]
15             ans = max(ans, gain[i])
16         return ans


Uriel 2023-06-19 16:27 鍙戣〃璇勮
]]>
[LeetCode]2352. Equal Row and Column Pairs (Medium) Python-2023.06.13http://www.shnenglu.com/Uriel/articles/229927.htmlUrielUrielTue, 13 Jun 2023 10:11:00 GMThttp://www.shnenglu.com/Uriel/articles/229927.htmlhttp://www.shnenglu.com/Uriel/comments/229927.htmlhttp://www.shnenglu.com/Uriel/articles/229927.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229927.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229927.html


 1 #2352
 2 #Runtime: 667 ms (Beats 25%)
 3 #Memory: 18 MB (Beats 22.98%)
 4 
 5 class Solution(object):
 6     def equalPairs(self, grid):
 7         """
 8         :type grid: List[List[int]]
 9         :rtype: int
10         """
11         l = len(grid)
12         ans = 0 
13         grid_trans = [[0] * l for _ in range(l)]
14         for i in range(l):
15             for j in range(l):
16                 grid_trans[i][j] = grid[j][i]
17         for i in grid:
18             for j in grid_trans:
19                 if i == j:
20                     ans += 1
21         return ans


Uriel 2023-06-13 18:11 鍙戣〃璇勮
]]>
[LeetCode]1351. Count Negative Numbers in a Sorted Matrix (Easy) Python-2023.06.08http://www.shnenglu.com/Uriel/articles/229923.htmlUrielUrielThu, 08 Jun 2023 05:31:00 GMThttp://www.shnenglu.com/Uriel/articles/229923.htmlhttp://www.shnenglu.com/Uriel/comments/229923.htmlhttp://www.shnenglu.com/Uriel/articles/229923.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229923.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229923.html
鎬濊礬涓錛氳涓父鏍囷紝璁板綍褰撳墠琛岄潪璐熸暟鏈夊嚑涓?br />

 1 #1351
 2 #Runtime: 95 ms (Beats 68.82%)
 3 #Memory: 14.5 MB (Beats 73.12%)
 4 
 5 class Solution(object):
 6     def countNegatives(self, grid):
 7         """
 8         :type grid: List[List[int]]
 9         :rtype: int
10         """
11         pos = len(grid[0])
12         ans = 0
13         for i in range(len(grid)):
14             for j in range(pos):
15                 if grid[i][j] < 0:
16                     pos = j
17                     break
18             ans += len(grid[0]) - pos
19         return ans


鎬濊礬浜岋細(xì)姣忚浜屽垎姹備綅緗紙澶嶆潅搴︽洿浣庯紝浣嗚繖棰樻暟鎹及璁″緢姘達(dá)紝鎵浠ュ弽鑰屾參錛?br />

 1 #1351
 2 #Runtime: 102 ms (Beats 25.81%)
 3 #Memory: 14.5 MB (Beats 40.86%)
 4 
 5 class Solution(object):
 6     def countNegatives(self, grid):
 7         """
 8         :type grid: List[List[int]]
 9         :rtype: int
10         """
11         def b_search(i):
12             l = 0
13             r = len(grid[i])
14             while l < r:
15                 mid = (l + r) // 2
16                 if grid[i][mid] >= 0:
17                     l = mid + 1
18                 else:
19                     r = mid
20             return l
21             
22         ans = 0
23         for i in range(len(grid)):
24             ans += len(grid[0]) - b_search(i)
25         return ans


Uriel 2023-06-08 13:31 鍙戣〃璇勮
]]>
[LeetCode]1502. Can Make Arithmetic Progression From Sequence (Easy) Python-2023.06.06http://www.shnenglu.com/Uriel/articles/229921.htmlUrielUrielTue, 06 Jun 2023 05:48:00 GMThttp://www.shnenglu.com/Uriel/articles/229921.htmlhttp://www.shnenglu.com/Uriel/comments/229921.htmlhttp://www.shnenglu.com/Uriel/articles/229921.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229921.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229921.html

 1 #1502
 2 #Runtime: 23 ms (Beats 81.90%)
 3 #Memory: 13.5 MB (Beats 61.90%)
 4 
 5 class Solution(object):
 6     def canMakeArithmeticProgression(self, arr):
 7         """
 8         :type arr: List[int]
 9         :rtype: bool
10         """
11         arr.sort()
12         inc = arr[1] - arr[0]
13         for i in range(2, len(arr)):
14             if arr[i] - arr[i - 1] != arr[1] - arr[0]:
15                 return False
16         return True


Uriel 2023-06-06 13:48 鍙戣〃璇勮
]]>
[LeetCode]1232. Check If It Is a Straight Line (Easy) Python-2023.06.05http://www.shnenglu.com/Uriel/articles/229919.htmlUrielUrielMon, 05 Jun 2023 04:44:00 GMThttp://www.shnenglu.com/Uriel/articles/229919.htmlhttp://www.shnenglu.com/Uriel/comments/229919.htmlhttp://www.shnenglu.com/Uriel/articles/229919.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229919.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229919.html

 1 #1232
 2 #Runtime: 45 ms (Beats 45.11%)
 3 #Memory: 13.9 MB (Beats 29.35%)
 4 
 5 class Solution(object):
 6     def checkStraightLine(self, coordinates):
 7         """
 8         :type coordinates: List[List[int]]
 9         :rtype: bool
10         """
11         eps = 1e-6
12         for k in range(2, len(coordinates)):
13             if coordinates[0][0] == coordinates[1][0]:
14                 if coordinates[k][0] != coordinates[0][0]:
15                     return False
16             else:
17                 if abs(coordinates[0][0] - coordinates[k][0]) < eps or abs(1.0 * (coordinates[0][1] - coordinates[1][1]) / (coordinates[0][0] - coordinates[1][0]) - 1.0 * (coordinates[0][1] - coordinates[k][1]) / (coordinates[0][0] - coordinates[k][0])) > eps:
18                     return False
19         return True


Uriel 2023-06-05 12:44 鍙戣〃璇勮
]]>
[LeetCode]1603. Design Parking System (Easy) Python-2023.05.29http://www.shnenglu.com/Uriel/articles/229910.htmlUrielUrielMon, 29 May 2023 15:08:00 GMThttp://www.shnenglu.com/Uriel/articles/229910.htmlhttp://www.shnenglu.com/Uriel/comments/229910.htmlhttp://www.shnenglu.com/Uriel/articles/229910.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229910.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229910.html

 1 #1603
 2 #Runtime: 115 ms (Beats 52.8%)
 3 #Memory: 14.1 MB (Beats 5.83%)
 4 
 5 class ParkingSystem(object):
 6 
 7     def __init__(self, big, medium, small):
 8         """
 9         :type big: int
10         :type medium: int
11         :type small: int
12         """
13         self.cnt_s = small
14         self.cnt_m = medium
15         self.cnt_b = big
16         
17 
18     def addCar(self, carType):
19         """
20         :type carType: int
21         :rtype: bool
22         """
23         if carType == 1:
24             if self.cnt_b > 0:
25                 self.cnt_b -= 1
26                 return True
27             else:
28                 return False
29         if carType == 2:
30             if self.cnt_m > 0:
31                 self.cnt_m -= 1
32                 return True
33             else:
34                 return False
35         if carType == 3:
36             if self.cnt_s > 0:
37                 self.cnt_s -= 1
38                 return True
39             else:
40                 return False
41         
42 
43 
44 # Your ParkingSystem object will be instantiated and called as such:
45 # obj = ParkingSystem(big, medium, small)
46 # param_1 = obj.addCar(carType)


Uriel 2023-05-29 23:08 鍙戣〃璇勮
]]>
[LeetCode]347. Top K Frequent Elements (Medium) Python-2023.05.22http://www.shnenglu.com/Uriel/articles/229902.htmlUrielUrielMon, 22 May 2023 08:20:00 GMThttp://www.shnenglu.com/Uriel/articles/229902.htmlhttp://www.shnenglu.com/Uriel/comments/229902.htmlhttp://www.shnenglu.com/Uriel/articles/229902.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229902.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229902.html

 1 #347
 2 #Runtime: 76 ms (Beats 90.9%)
 3 #Memory: 16.8 MB (Beats 53.94%)
 4 
 5 class Solution(object):
 6     def topKFrequent(self, nums, k):
 7         """
 8         :type nums: List[int]
 9         :type k: int
10         :rtype: List[int]
11         """
12         cnt = defaultdict(lambda:0)
13         for i in nums:
14             cnt[i] += 1
15         a = sorted(cnt.items(), key=lambda item: item[1], reverse=True)
16         ans = []
17         for x in a:
18             ans.append(x[0])
19         return ans[0:k]


Uriel 2023-05-22 16:20 鍙戣〃璇勮
]]>
[LeetCode]54. Spiral Matrix (Medium) Python-2023.05.09http://www.shnenglu.com/Uriel/articles/229872.htmlUrielUrielTue, 09 May 2023 06:48:00 GMThttp://www.shnenglu.com/Uriel/articles/229872.htmlhttp://www.shnenglu.com/Uriel/comments/229872.htmlhttp://www.shnenglu.com/Uriel/articles/229872.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229872.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229872.html
Input: matrix =[
[1,2,3],
[4,5,6],
[7,8,9]]
Output: [1,2,3,6,9,8,7,4,5]


 1 #54
 2 #Runtime: 18 ms (Beats 50.87%)
 3 #Memory: 13.3 MB (Beats 90.64%)
 4 
 5 class Solution(object):
 6     def spiralOrder(self, matrix):
 7         """
 8         :type matrix: List[List[int]]
 9         :rtype: List[int]
10         """
11         fg = [[0] * len(matrix[0]) for _ in range(len(matrix))]
12         ans = [matrix[0][0]]
13         fg[0][0] = 1
14         i, j, cnt, t = 0, 0, 1, 0
15         while cnt < len(matrix) * len(matrix[0]):
16             if t % 4 == 0:
17                 while j < len(matrix[0]) - 1 and not fg[i][j + 1]:
18                     j += 1
19                     ans.append(matrix[i][j])
20                     fg[i][j] = 1
21                     cnt += 1
22             elif t % 4 == 1:
23                 while i < len(matrix) - 1 and not fg[i + 1][j]:
24                     i += 1
25                     ans.append(matrix[i][j])
26                     fg[i][j] = 1
27                     cnt += 1
28             elif t % 4 == 2:
29                 while j >= 0 and not fg[i][j - 1]:
30                     j -= 1
31                     ans.append(matrix[i][j])
32                     fg[i][j] = 1            
33                     cnt += 1
34             elif t % 4 == 3:
35                 while i >= 0 and not fg[i - 1][j]:
36                     i -= 1
37                     ans.append(matrix[i][j])
38                     fg[i][j] = 1
39                     cnt += 1
40             t += 1
41         return ans


Uriel 2023-05-09 14:48 鍙戣〃璇勮
]]>
[LeetCode]1572. Matrix Diagonal Sum (Easy) Python-2023.05.08http://www.shnenglu.com/Uriel/articles/229870.htmlUrielUrielMon, 08 May 2023 06:48:00 GMThttp://www.shnenglu.com/Uriel/articles/229870.htmlhttp://www.shnenglu.com/Uriel/comments/229870.htmlhttp://www.shnenglu.com/Uriel/articles/229870.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229870.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229870.html

 1 #1572
 2 #Runtime: 93 ms (Beats 7.69%)
 3 #Memory: 13.7 MB (Beats 15.92%)
 4 
 5 class Solution(object):
 6     def diagonalSum(self, mat):
 7         """
 8         :type mat: List[List[int]]
 9         :rtype: int
10         """
11         ans = 0
12         for i in range(min(len(mat), len(mat[0]))):
13             ans += mat[i][i]
14         for i in range(min(len(mat), len(mat[0]))):
15             j = len(mat[0]) - i - 1
16             if i != j:
17                 ans += mat[i][j]
18         return ans


Uriel 2023-05-08 14:48 鍙戣〃璇勮
]]>
[LeetCode]2215. Find the Difference of Two Arrays (Easy) Python-2023.05.03http://www.shnenglu.com/Uriel/articles/229863.htmlUrielUrielThu, 04 May 2023 10:14:00 GMThttp://www.shnenglu.com/Uriel/articles/229863.htmlhttp://www.shnenglu.com/Uriel/comments/229863.htmlhttp://www.shnenglu.com/Uriel/articles/229863.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229863.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229863.html

 1 #2215
 2 #Runtime: 142 ms (Beats 72.81%)
 3 #Memory: 13.7 MB (Beats 71.49%)
 4 
 5 class Solution(object):
 6     def findDifference(self, nums1, nums2):
 7         """
 8         :type nums1: List[int]
 9         :type nums2: List[int]
10         :rtype: List[List[int]]
11         """
12         s1 = set(nums1)
13         s2 = set(nums2)
14         return [list(s1 - s2), list(s2 - s1)]


Uriel 2023-05-04 18:14 鍙戣〃璇勮
]]>
[LeetCode]1822. Sign of the Product of an Array (Easy) Python-2023.05.02http://www.shnenglu.com/Uriel/articles/229859.htmlUrielUrielTue, 02 May 2023 06:18:00 GMThttp://www.shnenglu.com/Uriel/articles/229859.htmlhttp://www.shnenglu.com/Uriel/comments/229859.htmlhttp://www.shnenglu.com/Uriel/articles/229859.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229859.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229859.html

 1 #1822
 2 #Runtime: 49 ms (Beats 14.51%)
 3 #Memory: 13.4 MB (Beats 85.49%)
 4 
 5 class Solution(object):
 6     def arraySign(self, nums):
 7         """
 8         :type nums: List[int]
 9         :rtype: int
10         """
11         t = 0
12         for i in nums:
13             if not i:
14                 return 0
15             if i < 0:
16                 t += 1
17         return -1 if t % 2 else 1


Uriel 2023-05-02 14:18 鍙戣〃璇勮
]]>
[LeetCode]1491. Average Salary Excluding the Minimum and Maximum Salary (Easy) Python-2023.05.01http://www.shnenglu.com/Uriel/articles/229858.htmlUrielUrielMon, 01 May 2023 12:28:00 GMThttp://www.shnenglu.com/Uriel/articles/229858.htmlhttp://www.shnenglu.com/Uriel/comments/229858.htmlhttp://www.shnenglu.com/Uriel/articles/229858.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229858.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229858.html

 1 #1491
 2 #Runtime: 21 ms (Beats 35.34%)
 3 #Memory: 13.4 MB (Beats 73.89%)
 4 
 5 class Solution(object):
 6     def average(self, salary):
 7         """
 8         :type salary: List[int]
 9         :rtype: float
10         """
11         ma = 0
12         mi = 1000001
13         s = 0
14         for i in salary:
15             if i < mi:
16                 mi = i
17             if i > ma:
18                 ma = i
19             s += i
20         return (s - mi - ma) / (len(salary) - 2.0)


Uriel 2023-05-01 20:28 鍙戣〃璇勮
]]>
[LeetCode]258. Add Digits (Easy) Python-2023.04.26http://www.shnenglu.com/Uriel/articles/229846.htmlUrielUrielWed, 26 Apr 2023 13:22:00 GMThttp://www.shnenglu.com/Uriel/articles/229846.htmlhttp://www.shnenglu.com/Uriel/comments/229846.htmlhttp://www.shnenglu.com/Uriel/articles/229846.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229846.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229846.html

 1 #258
 2 #Runtime: 23 ms (Beats 46.91%)
 3 #Memory: 13.3 MB (Beat 88.20%)
 4 
 5 class Solution(object):
 6     def addDigits(self, num):
 7         """
 8         :type num: int
 9         :rtype: int
10         """
11         while num >= 10:
12             t = num
13             num = 0
14             while t > 0:
15                 num += t % 10
16                 t = t // 10
17         return num


Uriel 2023-04-26 21:22 鍙戣〃璇勮
]]>
[LeetCode]1768. Merge Strings Alternately (Easy) Python-2023.04.18http://www.shnenglu.com/Uriel/articles/229828.htmlUrielUrielTue, 18 Apr 2023 09:28:00 GMThttp://www.shnenglu.com/Uriel/articles/229828.htmlhttp://www.shnenglu.com/Uriel/comments/229828.htmlhttp://www.shnenglu.com/Uriel/articles/229828.html#Feedback0http://www.shnenglu.com/Uriel/comments/commentRss/229828.htmlhttp://www.shnenglu.com/Uriel/services/trackbacks/229828.html

 1 #1768
 2 #Runtime: 19 ms (Beats 58.68%)
 3 #Memory: 13.6 MB (Beats 11.81%)
 4 
 5 class Solution(object):
 6     def mergeAlternately(self, word1, word2):
 7         """
 8         :type word1: str
 9         :type word2: str
10         :rtype: str
11         """
12         ans = []
13         for i in range(min(len(word1), len(word2))):
14             ans.append(word1[i])
15             ans.append(word2[i])
16         if i < len(word1):
17             ans.append(word1[i + 1:])
18         if i < len(word2):
19             ans.append(word2[i + 1:])
20         return ''.join(ans)



Uriel 2023-04-18 17:28 鍙戣〃璇勮
]]>
久久精品国产精品青草app| yellow中文字幕久久网| 久久强奷乱码老熟女网站| 久久精品成人一区二区三区| 久久精品国产乱子伦| 久久精品国产亚洲av高清漫画| 久久亚洲高清观看| 国产精品中文久久久久久久| 久久久久99精品成人片欧美| 亚洲国产天堂久久综合网站| 成人a毛片久久免费播放| 欧美激情精品久久久久久| 久久久久人妻精品一区| 9999国产精品欧美久久久久久 | 欧美日韩精品久久免费| 久久精品国产99国产精偷| 伊人久久大香线蕉av一区| 久久综合久久鬼色| 国产精品免费久久久久影院 | 人妻中文久久久久| 国产精品一区二区久久精品| 久久免费线看线看| 99re这里只有精品热久久| 国产∨亚洲V天堂无码久久久| 91视频国产91久久久| 中文字幕久久欲求不满| 久久久久香蕉视频| 久久精品免费一区二区| 久久精品国产亚洲AV大全| 久久精品男人影院| 久久久久久久综合日本| 2021最新久久久视精品爱| 亚洲午夜久久久久久久久久| aaa级精品久久久国产片| 国产精品亚洲综合专区片高清久久久| 久久久这里有精品中文字幕| 中文国产成人精品久久不卡| 久久久久综合网久久| 伊人精品久久久久7777| 久久九九精品99国产精品| 久久99国产精品成人欧美|