for i in range(13,17): print(i) #显示结果为: #13 #14 #15 #16 1. 2. 3. 4. 5. 6. 7. for i in range(n):,表示循环n次。如下面例题中i=0,i=1,i=2时都执行一次语句内的代码,也就是3次。 for i in range(3): print('我很棒') #结果显示为: #我很棒 #我很棒 #我很棒 1...
分析下process函数中只有i和j的变化会得到不同的结果,所以定义二维数组cache,初始化为None,长宽分别为s的长度m,因为字符串索引从0开始,所以字符串的长度可以包含所有字符串。 class Solution: def longestPalindromeSubseq(self, s: str) -> int: m = len(s) cache = [[None] * (m + 1) for _ in ra...
def longestCommonPrefix(strs): # 如果字符串数组为空或长度为0,直接返回空字符串 if not strs: return "" # 字符串数组的第一个字符串 firstStr = strs[0] # 遍历第一个字符串的每个字符 for i in range(len(firstStr)): c = firstStr[i] # 遍历剩余的字符串进行比较 for j in range(1, le...
print('today to learn the ') names = ['aa', 'bb', 'cc'] for i in names: print(i) # 使用range来生成1,2,3,4,5 for value in range(1, 5): print(value) # 使用range来生成1-15的奇数 number = list(range(1, 15, 2)) print(number) # 使用range来生成1-10的平方数 squares = ...
MAXSIZE = 20 def fibonacci(): # 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 f = [0] * MAXSIZE f[0] = 1 f[1] = 1 for i in range(2, MAXSIZE): f[i] = f[i-1] + f[i-2] return f def fibonacciSearch(array, value): low, mid, high = 0, 0, len(array)-1 k...
for (int i = 0; i < 10; i++) { final int index = i; executorService.execute(new Runnable() { @Override public void run() { log.info("task:{}",index); } }); } executorService.shutdown(); 线程池的相关信息可以看下这个链接:线程池相关概念 线程的生命周期;状态是如何转移的 线程的...
public static int[] range(int start,int end,int step){ int sz =(end-start)/step; int[] result=new int[sz]; for(int i=0;i<sz;i++) result[i]=start+(i*step); return result; } 这样的话我range(1,10,2),得到的是{1,3,5,7}这样的数组, 但我看到python中range的用法是range(1,...
for (int i = m; i > 0; i--) { if (caller i's domain does not have the permission) throw AccessControlException else if (caller i is marked as privileged) { if (a context was specified in the call to doPrivileged) context.checkPermission(permission) if (limited permissions were spe...
I. Development 1. Common frameworks and libraries Up Spring framework The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications -- on any kind of deployment platform. A key element of Spring is infrastructural support at the applicatio...
熟悉switch(byte|short|int|String|enum){case xx: yyy break },for循环(特别是两层嵌套)、while(条件){循环体;步长;},以及break和continue的用法和场景; 为什么数组获取长度用length,字符串获取长度用length(); Object类中常用的方法:getClass(),hashCode(),equals(),clone(),toString(),finalize()垃圾回收前...