- 博客(17)
- 收藏
- 关注
原创 Threshold Matters in WSSS: Manipulating the Activation for the Robust and Accurate Segmentation Mode
CVPR2022 弱监语义分割篇
2023-02-05 19:26:11 306 1
原创 两数相加最优解
class Solution:def twoSum(self,nums, target):“”":type nums: List[int]:type target: int:rtype: List[int]“”"#用len()方法取得nums列表长度n = len(nums)#创建一个空字典d = {}for x in range(n):a = target - nums[x]#字典d中存在nums[x]时if nums[x] in d:return d[nums[x]],x
2021-05-17 14:36:35 179
原创 2021-05-01
class Solution: def findTheDifference(self, s: str, t: str) -> str: ans = 0 for i in s: ans ^= ord(i) for i in t: ans ^= ord(i) return chr(ans)
2021-05-01 00:03:09 68 1
原创 191.1的个数
# 方法一def hammingWeight(n): res = 0 while n: res += n & 1 # 如果最后一位是1,交集为1 n >>= 1 # 向右移动一位 return res# 方法二:def hammingWeight1(n:int): return bin(n).count("1") # bin(666) = '0b1010011010'# 方法三:def hammingWei
2021-04-29 00:08:59 57
原创 2021-04-27
def majorityElement(nums): count = 0 res = 0 for i in nums: if count == 0: res = i if i == res: count = count + 1 else: count = count - 1 return res# 这方法只有在众数过半的时候才能用,不然很可能选不出最多的
2021-04-27 21:51:51 46
原创 136. singleNumber
def singleNumber(nums): for i in range(1, len(nums)): nums[0] ^= nums[i] return nums[0]# 异或运算满足交换律,a^b^a=a^a^b=b,因此相当于nums[0]^nums[1]^nums[2]^nums[3]^nums[4].....# 然后再根据交换律把相等的合并到一块儿进行异或(结果为0),# 然后再与只出现过一次的元素进行异或,这样最后的结果就是,只出现过一次的元素(0^任意
2021-04-26 23:43:46 47
原创 78.子集
from typing import Listdef subsets(nums: List[int]) -> List[List[int]]: res = [[]] for i in nums: a = [[i] + num for num in res] print(a) res = res + a # print(res) return resdef subsets2(nums: List[int])
2021-04-25 22:48:41 48
原创 9. 回文数
def isPalindrome(x: int) -> bool: if x < 0 or (x != 0 and x % 10 == 0): # 判断是否x<10 return False res = 0 while x > res: # 直到中间的时候停止 res = res * 10 + x % 10 # 保存后半部分 x = x // 10 # 消除最后一位 return (x == re
2021-04-24 19:44:12 42
原创 190.reverseBit
颠倒二进制位:def reverseBits(n:int): res = 0 for i in range(32): res = (res << 1) | (n & 1) n >>= 1 return res
2021-04-23 11:47:08 92
原创 7. reverse integer
def reverse(x: int): # this use the string if -10 < x < 10: return x str_x = str(x) if str_x[0] != '-': str_x = str_x[::-1] x = int(str_x) else: str_x = str_x[:0:-1] x = int(str_x) x = -x re
2021-04-22 20:52:56 49
原创 深度学习之线性回归
CNN之线性回归import randomfrom mxnet import autograd, nddef data_iter(batch_sizes, feature, result): num = len(feature) indices = list(range(num)) random.shuffle(indices) # read the data randomly for i in range(0, num, batch_size):
2021-04-21 22:46:53 167 2
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人