本站消息

  出租广告位,需要合作请联系站长

  今日名言-想象你自己对困难作出的反应,不是逃避或绕开它们,而是面对它们,同它们打交道,以一种进取的和明智的方式同它们奋斗 。——马克斯威尔·马尔兹

  今日名言-用谅解、宽恕的目光和心理看人、待人。人就会觉得葱笼的世界里,春意盎然,到处充满温暖。——蔡文甫


+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

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

发布于2021-07-25 06:38     阅读(526)     评论(0)     点赞(10)     收藏(4)


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.

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



所属网站分类: 技术文章 > 博客

作者:风雨雷电

链接:http://www.pythonpdf.com/blog/article/428/b4a2b5784efd9b152669/

来源:编程知识网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

10 0
收藏该文
已收藏

评论内容:(最多支持255个字符)