摘要:
C++的实现: 1 class Solution { 2 public: 3 int maxRotateFunction(vector<int>& A) { 4 long N = A.size(); 5 long S = 0; 6 long t = 0; 7 for (int i = 0; i <
阅读全文
posted @ 2020-04-09 10:43
Sempron2800+
阅读(181)
推荐(0)
编辑
摘要:
1 class Solution: 2 def validUtf8(self, data): 3 # 标记这个字节是某个编码的第几个字节 4 n_bytes = 0 5 6 # 遍历数组 7 for num in data: 8 9 # 获取二进制编码,保留最低8位 10 bin_rep = for
阅读全文
posted @ 2020-04-09 10:42
Sempron2800+
阅读(198)
推荐(0)
编辑
摘要:
1 class Solution { 2 public: 3 int lastRemaining(int n) { 4 if (n == 1) return 1; 5 return 2 * (n / 2 + 1 - lastRemaining(n / 2)); 6 7 // vector<int>
阅读全文
posted @ 2020-04-09 10:40
Sempron2800+
阅读(217)
推荐(0)
编辑
摘要:
1 class Solution(object): 2 def lengthLongestPath(self, input): 3 """ 4 :type input: str 5 :rtype: int 6 """ 7 input = input.split('\n') 8 res = 0 9 s
阅读全文
posted @ 2020-04-09 10:34
Sempron2800+
阅读(155)
推荐(0)
编辑
摘要:
1 class Solution: 2 def kSmallestPairs(self, nums1, nums2, k): 3 queue = [] 4 def push(i, j): 5 if i < len(nums1) and j < len(nums2): 6 heapq.heappush
阅读全文
posted @ 2020-04-09 10:30
Sempron2800+
阅读(226)
推荐(0)
编辑
摘要:
1 class Solution(object): 2 def largestDivisibleSubset(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype: List[int] 6 """ 7 # The container that hol
阅读全文
posted @ 2020-04-09 10:27
Sempron2800+
阅读(132)
推荐(0)
编辑
摘要:
1 class Solution: 2 def superPow(self, a: int, b: List[int]) -> int: 3 return pow(a,int(''.join(map(str,b))),1337) 算法思路:直接调用python的pow函数。 学有余力的同学,可以尝试
阅读全文
posted @ 2020-04-09 10:18
Sempron2800+
阅读(128)
推荐(0)
编辑