Skip to content

Create 2023 0207 array and string.md #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions 紀錄/2023 0207 array and string.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Y.J. Lee
8:28 PM
空格問清楚算不算
counter從頭走到尾一遍 就知道答案了
Y.J. Lee
8:51 PM
這題很多edge case
最簡單應該是DP
Y.J. Lee
9:03 PM
這個解法不錯https://leetcode.com/problems/one-edit-distance/discuss/238517/Python%3A-Simple-Clear-beats-100-time-and-memory
莊惠文
9:04 PM
meta.title
That topic does not exist.
@@
Y.J. Lee
9:04 PM
DP是通用解法
莊惠文
9:05 PM
網址點進去
Y.J. Lee
9:05 PM
QQ!
Y.J. Lee
9:07 PM
72 edit distance (基本型)
161 one edit distance (locked)
Y.J. Lee
9:08 PM
class Solution(object):
def isOneEditDistance(self, s, t):
“”"
:type s: str
:type t: str
:rtype: bool
“”"
if s == t: return False
i = 0
while i < min(len(s),len(t)):
if s[i] == t[i]:
i += 1
else:
break
return s[i+1:] == t[i+1:] or s[i:] == t[i+1:] or s[i+1:]==t[i:]
161