题目简述 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。 你可以按任意顺序返回答案。 示例 1: 输入:nums = ...
转载
2021-09-15 20:45:00
67阅读
2评论
代码 class Solution: def isValid(self, s: str) -> bool: while True: if '[]' in s: s = s.replace('[]', '') elif '{}' in s: s = s.replace('{}', '') elif ...
转载
2021-10-28 13:18:00
46阅读
2评论
DescriptionRoman numerals are represented by seven different symbols
原创
2022-08-11 21:52:31
65阅读
给定结点数n,结点值为1,2,...,n,求由这些结点可以构成的所有二叉查找树。Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example, Given n = 3, your program should return all 5 unique BST's shown below. 1 3 3 2 1 \ / / / \ \ 3 2 ...
转载
2013-09-15 19:07:00
42阅读
2评论
Error:cannot solve it. Assume, for each plus sign L_total, we have:L_total = min(L_up, L_down, L_left, L_right)So we can calculate the acc
原创
2023-08-23 09:12:29
98阅读
Error:cannot solve it. So stupid.Use dfs to solve it. Actually we can use BFS, which is simpler. But I think dfs is something we use mostly. In dfs, iterate all node, then cou
原创
2023-08-23 09:13:12
69阅读
利用双指针实现原地修改数据,就不需要在开辟新的存储空间/**<p>给你一个数组 <code>nums</code> 和一个值 <code>val</code>,你需要 <strong><a href="https://baike.baidu.com/item/%E5%8E%9F%
原创
2022-09-11 17:20:04
128阅读
1518. 换酒问题小区便利店正在促销,用 numExchange 个空酒瓶可以兑换一瓶新酒。你购入了 numBottles 瓶酒。如果喝掉了酒瓶中的酒,那么酒瓶就会变成空的。请你计算 最多 能喝到多少瓶酒。//直接模拟class Solution {public: int numWaterBottles(int numBottles, int numExchange) { int a=numBottles,b=numBottles; while(a&
原创
2021-06-07 21:43:09
223阅读
思路是:双指针去头尾空格,然后遍历中间去空格直到每个单词后最多一个空格;然后将整个字符串翻转,然后从头遍历将遇到的单词翻转回去; 一开始因为while (s[end] == ' ' && end >= 0) //除去结尾空格end>=0不严谨,导致案例" "死活不通过,我以为结果有问题,试了几次才发现end在这个案例中会减到-1,使得s[-1]这种溢出情
原创
2022-01-04 18:05:23
100阅读
# Python实现一个算法:识别一个字符串中是否包含唯一的字符
## 引言
在字符串处理中,经常需要判断一个字符串中是否包含唯一的字符。例如,在密码验证、数据清洗和字符统计等场景中,我们需要确保字符串中没有重复的字符。
本文将介绍一种简单而高效的算法,用于判断一个字符串中是否包含唯一的字符。我们将使用Python编程语言实现该算法,并通过代码示例进行演示。
## 算法思路
我们可以使用
原创
2023-08-18 16:47:50
290阅读
https://leetcod-super-ugly-number/
原创
2023-06-29 11:10:09
33阅读
404. Sum of Left Leaves*
https://leetcod
/ \
9 20
/ \
15 7
There are two ...
原创
2022-05-30 10:54:15
40阅读
welcome to my blogLeetCode 502. IPO (Java版; Hard)题目描述Suppose LeetCod
原创
2023-01-18 09:49:26
103阅读
Problem: 1805. 字符串中不同整数的数目 lc题解地址 https://leetcod
原创
2022-12-10 15:38:14
68阅读
Word Break Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcod
原创
2023-02-17 09:34:05
41阅读
原题链接在这里:https://leetcode.com/problems/encode-and-decode-tinyurl/ 题目: TinyURL is a URL shortening service where you enter a URL such as https://leetcod
转载
2017-11-15 17:05:00
88阅读
2评论