0


Python 刷Leetcode题库,顺带学英语单词(46)

Isomorphic Strings

Given two strings s and t, determine if they are isomorphic.
Two strings are isomorphic if the characters in s can be replaced to get t. [#205]
All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character but a character may map to itself.

Examples:
Input: s = "egg", t = "add"
Output: true
Input: s = "foo", t = "bar"
Output: false
Input: s = "paper", t = "title"
Output: true

Note:
You may assume both s and t have the same length.


Word Pattern

Given a pattern and a string str, find if str follows the same pattern. [#290]
Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.

Examples:
Input: pattern = "abba", str = "dog cat cat dog"
Output: true
Input:pattern = "abba", str = "dog cat cat fish"
Output: false
Input: pattern = "aaaa", str = "dog cat cat dog"
Output: false
Input: pattern = "abba", str = "dog dog dog dog"
Output: false

Note:
You may assume pattern contains only lowercase letters, and str contains lowercase letters separated by a single space.

题意:给定一个模式串,判断字符串和给定模式串是否为相同模式。

标签:

本文转载自: https://blog.csdn.net/boysoft2002/article/details/119024995
版权归原作者 Hann Yang 所有, 如有侵权,请联系我们删除。

“Python 刷Leetcode题库,顺带学英语单词(46)”的评论:

还没有评论