Re: [闲聊] 每日LeetCode

楼主: Rushia (みけねこ的鼻屎)   2023-07-03 23:38:23
https://leetcode.com/problems/buddy-strings/
859. Buddy Strings
给你一个字串 s 和一个字串 goal,如果 s 的两个字符交换一次后等于 goal 则他是
一个 Buddy Strings,判断 s 是否是一个 Buddy Strings。
Example 1:
Input: s = "ab", goal = "ba"
Output: true
Explanation: You can swap s[0] = 'a' and s[1] = 'b' to get "ba", which is
equal to goal.
Example 2:
Input: s = "ab", goal = "ab"
Output: false
Explanation: The only letters you can swap are s[0] = 'a' and s[1] = 'b',
which results in "ba" != goal.
Example 3:
Input: s = "aa", goal = "aa"
Output: true
Explanation: You can swap s[0] = 'a' and s[1] = 'a' to get "aa", which is
equal to goal.
思路:
1.一个一个排掉corner case
Java Code:
作者: lopp54321010 (嘻嘻010)   2023-07-03 23:40:00
好粗暴的easy哦
作者: JIWP (JIWP)   2023-07-03 23:43:00
大师
作者: Che31128 (justjoke)   2023-07-03 23:55:00
这题真的很粗暴

Links booklink

Contact Us: admin [ a t ] ucptt.com