leedcode

leedcode 合并两个有序链表

class Solution(object): def mergeTwoLists(self, list1, list2): if not list1: return list2 if not list2: return list1 result = None while list1 or list ......
leedcode 两个

leedcode 有效的括号

暴力求解 class Solution: def isValid(self, s: str) -> bool: s_len = len(s) s_list = list() kuohao_list = ['(', ')', '[', ']', '{', '}', 'n'] for i in rang ......
括号 leedcode

leedcode 寻找公共前缀

第一版 用find函数 但不能找出开头有重复的 class Solution:#不能找开头有重复的 def longestCommonPrefix(self, strs): str_num=len(strs) com_list=list() min_len=100 for i in strs: mi ......
前缀 leedcode

leedcode 罗马数字转整数

class Solution: def romanToInt(self, s: str) -> int: num_convert = {'I': 1, 'V': 5, 'X':10,'L':50,'C':100,'D':500,'M':1000} s_len=len(s) count=0 for i ......
整数 leedcode 数字

leedcode 回文数

class Solution: def isPalindrome(self, x: int) -> bool: x_str=str(x) x_str_len=len(x_str) if x_str_len==1: return True count=0 for i in range(x_str_le ......
回文 leedcode

2023.12.28 leedcode 两数之和

class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: for i in range(len(nums)): if target - nums[i] in nums[i + 1 :]: if i != ......
之和 leedcode 2023 12 28

LeedCode刷题(2)-Java随机数练习

2.随机数练习 (1)随机生成数 题目:请编写如下所示程序 随机生成并显示一位数的正整数(1~9的值) 随机生成并显示一位数的负整数(-9 ~ -1的值) 随机生成并显示两位数的正整数(10~99的值) ①Random类总结 random是Java提供的一个类库,它的实例会生成一连串的伪随机数 Ra ......
随机数 LeedCode Java

LeedCode刷题(1)-交替合并字符串

1.交替合并字符串 题目:给你两个字符串word1和word2。请你从word1开始,通过交替添加字母来合并字符串。如果一个字符串比另一个字符串长,就将多出来的字母追加到合并字符串的末尾。 示例 1: 输入:word1 = "abc", word2 = "pqr" 输出:"apbqcr" 解释:字符 ......
字符串 字符 LeedCode
共8篇  :1/1页 首页上一页1下一页尾页