自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

ailinyingai的博客

努力 持之以恒

  • 博客(28)
  • 收藏
  • 关注

原创 297 序列化和反序列化

/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Codec { String SEP=","; String NULL="#"; // Encodes a

2021-01-23 19:39:04 115

原创 0023

# class ListNode:# def __init__(self, val=0, next=None):# self.val = val# self.next = nextclass Solution: def mergeKLists(self, lists: List[ListNode]) -> ListNode: if not lists: return n = len(lis

2021-01-21 21:15:49 83 1

翻译 go内置容器

数组 array切片 slice对比一下可以发现,唯一的区别就在于,数组是使用 [5]int{xxx} 来进行初始化,而 slice 是使用 []int{xxx}。在Go中,我们经常使用slice。slice的特点是,长度是可以改变的,也就是说,我们可以无限追加元素到slice中。其他特点slice与数组并无区别。mapmap是哈希表,Go语言中,声明一个map是这样用:var x map[string]string但是注意,上面只是说明x的类型是 map[string]string,但是x的

2021-01-21 18:58:39 124 1

翻译 golang基本类型

如果你学过计算机组成的话,就应该知道,现在的计算机是都是基于二进制,而二进制只能表示两个状态,1和0。其实我们平时在 计算机上看到的所有东西,例如一个字符串,一个整数,一张图片,一个网页等等,他们在最底层,都是一长串的0和1。那么我们怎么知道哪些0和1是字符串,哪些0和1是整数呢?其实这是人为规定的。我们把一个0或1,也就是最小的单位,叫做一个bit。 而把8个这样的单位组合在一起,叫做一个byte,也就是说,1 byte = 8 bit。既然一个bit能表示两个状态,那么八个bit就能表示 2 ** 8

2021-01-21 18:56:47 342

原创 矩阵旋转

def rotate_matrix(matrix): """rotates a matrix 90 degrees clockwise""" n = len(matrix) for layer in range(n // 2): first, last = layer, n - layer - 1 for i in range(first, last): # save top top = matrix[l

2021-01-21 14:27:56 93

原创 字符串转url

def urlify_algo(string, length): """replace spaces with %20 and removes trailing spaces""" # convert to list because Python strings are immutable char_list = list(string) string = "" new_index = len(char_list) for i in reversed(ran

2021-01-21 14:19:21 1878

翻译 检测排列组合

def check_permutation_by_sort(s1, s2): if len(s1) != len(s2): return False s1, s2 = sorted(s1), sorted(s2) for i in range(len(s1) - 1): if s1[i] != s2[i]: return False return Truedef check_permutation_by_count

2021-01-21 14:18:00 120

翻译 is_unique

def is_unique_chars_algorithmic(string): # Assuming character set is ASCII (128 characters) if len(string) > 128: return False # this is a pythonic and faster way to initialize an array with a fixed value. careful though # it wo

2021-01-21 14:14:08 162

原创 三数之和

class Solution(object): def threeSum(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ if len(nums) < 3: return [] nums.sort() res = set() for i, v in enume

2021-01-18 19:19:44 86

原创 爬楼梯

# 直接递归解法,容易超时,python可以加个缓存装饰器,这样也算是将递归转换成迭代的形式了# 除了这种方式,还有增加步长来递归,变相的减少了重复计算# 还有一种方法,在递归的同时,用数组记忆之前得到的结果,也是减少重复计算class Solution: @functools.lru_cache(100) # 缓存装饰器 def climbStairs(self, n: int) -> int: if n == 1: return 1 if n

2021-01-18 19:08:05 80

原创 盛最多水的容器

class Solution: def maxArea(self, height: List[int]) -> int: l, r = 0, len(height) - 1 ans = 0 while l < r: area = min(height[l], height[r]) * (r - l) ans = max(ans, area) if height[l] &

2021-01-18 18:49:59 82

原创 移动零

class Solution(object): def moveZeroes(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ idxs = [idx for idx , num in enumerate(nums) if num == 0]

2021-01-18 15:59:38 78

翻译 足球队 循环赛制

from collections import dequeimport randomdef build_schedule(_teamarr): scheduleobj = dict.fromkeys(range(1,20)) fixpos = _teamarr[0] ring = _teamarr[1:] ring = deque(ring) #前半赛程,1-19轮(round) for round in range(1,20): #第1支

2021-01-17 19:38:15 700

翻译 pod参数详解

apiVersion: v1    #必选,版本号,例如v1,版本号必须可以用 kubectl api-versions 查询到 .kind: Pod        #必选,Podmetadata:        #必选,元数据 name: string    #必选,Pod名称 namespace: string    #必选,Pod所属的命名空间,默认

2021-01-14 19:21:28 1204

原创 三次握手 四次握手

三次握手的作用也是有好多的,多记住几个,保证不亏。例如:1、确认双方的接受能力、发送能力是否正常。2、指定自己的初始化序列号,为后面的可靠传送做准备。3、如果是 https 协议的话,三次握手这个过程,还会进行数字证书的验证以及加密密钥的生成到。1、(ISN)是固定的吗三次握手的一个重要功能是客户端和服务端交换ISN(Initial Sequence Number), 以便让对方知道接下来接收数据的时候如何按序列号组装数据。如果ISN是固定的,攻击者很容易猜出后续的确认号,因此 ISN 是动态生

2021-01-11 23:48:38 113

原创 123另外的解

class Solution: def maxProfit(self, prices: List[int]) -> int: n = len(prices) if n == 0: return 0 minPri, maxPro1 = prices[0], 0 # 顺序遍历的最小pirce和最大利润 maxPri, maxPro2 = prices[-1],0 # 逆序遍历的最大price和最大利润

2021-01-09 22:50:43 97

原创 121

class Solution: def maxProfit(self, prices: List[int]) -> int: if len(prices) == 0: return 0 maxPro, minPrice = 0, prices[0] for i in range(1,len(prices)): if prices[i] <= minPrice: minPrice = prices[i]

2021-01-09 22:49:08 82

翻译 123

class Solution(object): def maxProfit(self, prices): n = len(prices) buy1 = buy2 = -prices[0] sell1 = sell2 = 0 for i in range(1, n): buy1 = max(buy1, -prices[i]) sell1 = max(sell1, buy1 + prices[

2021-01-09 22:18:37 72

原创 142

class Solution(object): def detectCycle(self, head): """ :type head: ListNode :rtype: ListNode """ hash_set = set() while head: if head in hash_set: return head has

2021-01-07 22:51:53 83

原创 46全排列

class Solution(object): def permute(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ def backtrack(first = 0): # 所有数都填完了 if first == n: res.append(nums[

2021-01-07 22:49:32 114

翻译 141 环形链表

class Solution(object): def hasCycle(self, head): """ :type head: ListNode :rtype: bool """ if not head: return False p1 = p2 = head # p1每次跑1步,p2每次跑2步 while p2.next and p2.next

2021-01-07 22:47:25 86 1

翻译 HPA2

Kubernetes具有灵活的可扩展性,它通过API聚合器为开发人员提供了轻松扩展API资源的能力,可以自定义指标API和资源指标API。新一代的Kubernetes监控系统架构主要由核心指标流水线和监控指标流水线协同组成。核心指标流水线由kubelet、metrics-server以及由API server提供的api组成;CPU累积使用率、内存的实时使用率、pod的资源占用率及容器的磁盘占用率。监控指标流水线用于从系统收集各种指标数据并提供给终端用户、存储系统以及HPA,包含核心指标以及其他许多

2021-01-07 16:26:34 260

原创 打家劫舍系列

class Solution { public int rob(int[] nums) { int n=nums.length; int a_i=0, b_i=0; int dp_i=0; for(int i=n-1;i>=0;i--){ dp_i=Math.max(dp_i, nums[i]+b_i); b_i=a_i; a_i=dp_i; .

2021-01-04 22:17:36 113 1

原创 k8s--ingress

PVC:Pod 想要使用的持久化存储的属性,比如存储的大小、读写权限等。PV :具体的 Volume 的属性,比如 Volume 的类型、挂载目录、远程存储服务器地址等。StorageClass:充当 PV 的模板。并且,只有同属于一个 StorageClass 的 PV 和 PVC,才可以绑定在一起。当然,StorageClass 的另一个重要作用,是指定 PV 的 Provisioner(存储插件)。这时候,如果你的存储插件支持 Dynamic Provisioning 的话,Kubernetes

2021-01-03 22:46:55 126

翻译 leetcode-1312

翻转一下 比对class Solution: def minInsertions(self, s: str) -> int: n = len(s) t = s[::-1] dp = [[0] * (n + 1) for _ in range(n + 1)] for i in range(1, n + 1): for j in range(1, n + 1): dp[i][j

2021-01-02 20:10:42 184

原创 leetcode-130

class Solution(object): def solve(self, board): """ :type board: List[List[str]] :rtype: void Do not return anything, modify board in-place instead. """ def fill(x, y): if x < 0 or x > m - 1 or

2021-01-02 20:05:39 117 1

翻译 k8s pod

pod 定义由这么几个部分组成: 首先是yaml中使用的Kubernetes API版本和YAML 描述的kind资源类型;所有Kubernetes资源中都可以找到的五大大重要部分:• apiVersion 使用的Kubernetes API版本• kind 资源类型• metadata 包括名称、命名空间、标签和关于该容器的其他信息。• spec 包含pod 内容的实际说明, 例如pod 的容器、卷和其他据。• status 包含运行中的pod 的当前信息,例如pod 所处的条件、每个容器的描

2021-01-02 15:46:47 134

原创 leetcode 1118 一月有多少天

class Solution: def numberOfDays(self, Y: int, M: int) -> int: D = [31,28,31,30,31,30,31,31,30,31,30,31] if Y % 400 == 0 or Y % 4 == 0 and Y % 100 != 0: D[1] += 1 return D[M - 1]

2021-01-01 22:08:39 109

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除