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