返回

每日leetcode打卡,第71题《找不同》等你挑战!

Android







## LeetCode每日打卡——第71题《找不同》

大家好,欢迎来到每日LeetCode打卡,今天我们来聊聊第71题《找不同》。

这道题给出了两个字符串`s`和`t`,它们只包含小写字母。字符串`t`是由字符串`s`随机重新排列组成。你需要找出`t`与`s`之间不同的字符。

乍一看,这道题似乎很简单,但其实有一定的难度。因为我们不能直接比较两个字符串,因为它们可能长度不同。我们需要找到一种方法来比较这两个字符串,而不会受到长度的影响。

一种解决方法是使用哈希表。我们可以把字符串`s`中的每个字符及其出现的次数存储在哈希表中。然后,我们可以遍历字符串`t`,并检查每个字符是否在哈希表中。如果不在,则说明这个字符是`t`中独有的。如果在,则我们需要检查这个字符出现的次数是否与哈希表中记录的次数相同。如果不相同,则说明这个字符在`t`中出现的次数与`s`中不同。

另一种解决方法是使用排序。我们可以先对字符串`s`和`t`进行排序,然后比较这两个字符串。如果两个字符串相等,则说明它们没有不同。如果不相等,则我们可以找到第一个不同的字符。

当然,还有一些其他的方法可以解决这道题。大家可以根据自己的情况选择合适的方法。

## 总结

好了,这就是今天LeetCode打卡的全部内容。希望大家能够喜欢。我们明天见!

## **每日LeetCode打卡题解清单** 

| 题目编号 | 题目名称 | 难度 | 解题链接 |
|---|---|---|---|
| 1 | 两数之和 | 简单 | [点击查看](https://leetcode-cn.com/problems/two-sum/solution/) |
| 2 | 两数相加 | 简单 | [点击查看](https://leetcode-cn.com/problems/add-two-numbers/solution/) |
| 3 | 无重复字符的最长子串 | 中等 | [点击查看](https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/solution/) |
| 4 | 寻找两个有序数组的中位数 | 困难 | [点击查看](https://leetcode-cn.com/problems/median-of-two-sorted-arrays/solution/) |
| 5 | 最长回文子串 | 中等 | [点击查看](https://leetcode-cn.com/problems/longest-palindromic-substring/solution/) |
| 6 | Z 字形变换 | 中等 | [点击查看](https://leetcode-cn.com/problems/zigzag-conversion/solution/) |
| 7 | 整数反转 | 简单 | [点击查看](https://leetcode-cn.com/problems/reverse-integer/solution/) |
| 8 | 字符串转换整数 (atoi) | 中等 | [点击查看](https://leetcode-cn.com/problems/string-to-integer-atoi/solution/) |
| 9 | 回文数 | 简单 | [点击查看](https://leetcode-cn.com/problems/palindrome-number/solution/) |
| 10 | 正则表达式匹配 | 困难 | [点击查看](https://leetcode-cn.com/problems/regular-expression-matching/solution/) |
| 11 | 盛最多水的容器 | 中等 | [点击查看](https://leetcode-cn.com/problems/container-with-most-water/solution/) |
| 12 | 整数转罗马数字 | 中等 | [点击查看](https://leetcode-cn.com/problems/integer-to-roman/solution/) |
| 13 | 罗马数字转整数 | 简单 | [点击查看](https://leetcode-cn.com/problems/roman-to-integer/solution/) |
| 14 | 最长公共前缀 | 简单 | [点击查看](https://leetcode-cn.com/problems/longest-common-prefix/solution/) |
| 15 | 三数之和 | 中等 | [点击查看](https://leetcode-cn.com/problems/3sum/solution/) |
| 16 | 最接近的三数之和 | 中等 | [点击查看](https://leetcode-cn.com/problems/3sum-closest/solution/) |
| 17 | 电话号码的字母组合 | 中等 | [点击查看](https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number/solution/) |
| 18 | 四数之和 | 中等 | [点击查看](https://leetcode-cn.com/problems/4sum/solution/) |
| 19 | 删除链表的倒数第N个节点 | 中等 | [点击查看](https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/solution/) |
| 20 | 有效的括号 | 简单 | [点击查看](https://leetcode-cn.com/problems/valid-parentheses/solution/) |
| 21 | 合并两个有序链表 | 简单 | [点击查看](https://leetcode-cn.com/problems/merge-two-sorted-lists/solution/) |
| 22 | 产生随机数 | 简单 | [点击查看](https://leetcode-cn.com/problems/generate-random-number/solution/) |
| 23 | 合并K个排序链表 | 困难 | [点击查看](https://leetcode-cn.com/problems/merge-k-sorted-lists/solution/) |
| 24 | 两两交换链表中的节点 | 简单 | [点击查看](https://leetcode-cn.com/problems/swap-nodes-in-pairs/solution/) |
| 25 | K 个一组翻转链表 | 中等 | [点击查看](https://leetcode-cn.com/problems/reverse-nodes-in-k-group/solution/) |
| 26 | 删除排序数组中的重复项 | 简单 | [点击查看](https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/solution/) |
| 27 | 移除元素 | 简单 | [点击查看](https://leetcode-cn.com/problems/remove-element/solution/) |
| 28 | 实现strStr() | 简单 | [点击查看](https://leetcode-cn.com/problems/implement-strstr/solution/) |
| 29 | 两数相除 | 中等 | [点击查看](https://leetcode-cn.com/problems/divide-two-integers/solution/) |
| 30 | 子串的个数 | 中等 | [点击查看](https://leetcode-cn.com/problems/substring-with-concatenation-of-all-words/solution/) |
| 31 | 下一个排列 | 中等 | [点击查看](https://leetcode-cn.com/problems/next-permutation/solution/) |
| 32 | 最长有效括号 | 困难 | [点击查看](https://leetcode-cn.com/problems/longest-valid-parentheses/solution/) |
| 33 | 搜索旋转排序数组 | 中等 | [点击查看](https://leetcode-cn.com/problems/search-in-rotated-sorted-array/solution/) |
| 34 | 在排序数组中查找元素的第一个和最后一个位置 | 中等 | [点击查看](https://leetcode-cn.com/problems/find-first-and-last-position-of-element-in-sorted-array/solution/) |
| 35 | 搜索插入位置 | 简单 | [点击查看](https://leetcode-cn.com/problems/search-insert-position/solution/) |
| 36 | 有效的数独 | 中等 | [点击查看](https://leetcode-cn.com/problems/valid-sudoku/solution/) |
| 37 | 解数独 | 困难 | [点击查看](https://leetcode-cn.com/problems/sudoku-solver/solution/) |
| 38 | 外观数列 | 简单 | [点击查看](https://leetcode-cn.com/problems/count-and-say/solution/) |
| 39 | 组合总和 | 中等 | [点击查看](https://leetcode-cn.com/problems/combination-sum/solution/) |
| 40 | 组合总和 II | 中等 | [点击查看](https://leetcode-cn.com/problems/combination-sum-ii/solution/) |
| 41 | 缺失的第一个正数 | 中等 | [点击查看](https://leetcode-cn