LeetCode Oj 290. Word Pattern

单片机笔记十二:华大HC32L136超低功耗设计实战 本文详细介绍了华大HC32L136单片机的超低功耗设计实战,包括深度睡眠模式下仅0.5μA的电流消耗、五种功耗模式的对比与配置、外设使用技巧及硬件级优化方法。通过实际项目案例,展示了如何利用ARM Cortex-M0+内核的HC32L136显著延长电池寿命,适用于智能门锁、额温枪等低功耗设备。 阅读详情

290. Word Pattern

 
  My Submissions
  • Total Accepted: 43861
  • Total Submissions: 144885
  • Difficulty: Easy

Given a pattern and a string str, find if str follows the same pattern.

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:

  1. pattern = "abba", str = "dog cat cat dog" should return true.
  2. pattern = "abba", str = "dog cat cat fish" should return false.
  3. pattern = "aaaa", str = "dog cat cat dog" should return false.
  4. pattern = "abba", str = "dog dog dog dog" should return false.

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

Credits:



class Solution {
public:
    bool wordPattern(string pattern, string str) {
        int vis[500];
        memset(vis , 0, sizeof(vis));
        map<int,string>mp;
        map<string,int>b_mp;
        vector<int>a;
        vector<string>b;
        for(int i=0;i<pattern.length();i++)
           a.push_back(pattern[i]);
        string t="";
        str=str+" ";
        for(int i=0;i<str.length();i++)
           if(str[i]==' ')
            {
                b.push_back(t);
                t="";
            }
           else
            {
                 t=t+str[i];
            }
    if(a.size()!=b.size()) return false;

    for(int i=0;i<a.size();i++)
        {
            if(!vis[a[i]])
            {
                if(b_mp[b[i]]) return false;

                vis[a[i]]=1;
                mp[a[i]]=b[i];
                vis[a[i]]=1;
                b_mp[b[i]]=a[i];
            }
            else
            {
                if(mp[a[i]]!=b[i]) return false;
            }
        }
    return true;
    }
};


深入解析WIFI与蓝牙模块电路设计:从原理到实战 本文深入解析了WIFI与蓝牙模块的电路设计,从核心原理到实战应用。文章以AP6256模块为例,详细拆解了电源树、时钟电路、接口设计及天线射频路径等关键环节,并提供了PCB布局布线的实用准则与调试方法,旨在帮助硬件工程师设计出稳定可靠的无线产品,规避常见陷阱。 阅读详情

相关推荐

RL调参侠之BipedalWalker BipedalWalkerHardcore SAC

前几天用PPO训练了个很一般的agent: RL调参侠之BipedalWalker PPO 我看SpinningUp上面说PPO和SAC是两个领域里各自的State_of_the_art的方法,所以就打算跑SAC试试看,之前因为Open AI Five的原因,一直感觉PPO很牛掰,实际上现在很多自动驾驶的算法也是用PPO在跑,毕竟有一个“必定能够提升期望”的理论保证在这里,我理解这对做项目很大的诱惑。 不过我跑出来的结果明显是SAC更好。 调参侠时间 策略熵的权重alpha用的0.2,我一开始没有看SAC的

weixin_48370148的博客 2100

LeetCode:Word Pattern

Word Pattern Total Accepted: 21299 Total Submissions: 77656 Difficulty: Easy Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match,

walker lee 525

告别手动发日报!用n8n+钉钉打造智能报告机器人(含模板下载)

本文详细介绍了如何利用n8n开源工作流自动化平台与钉钉机器人搭建智能日报系统,实现数据自动采集、处理和发送。通过实战步骤和模板下载,帮助用户告别手动处理日报的繁琐,提升工作效率和数据准确性。

h3i4j的博客 856

290. Word Pattern(技巧:记录当前位置来判断两个字符串是否符合)

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

u010005161的博客 1191

浙政钉(专有钉钉)门户免登(超详细)

钉钉家族 介绍浙政钉门户免登之前,首先搞清楚几个软件的关系,软件分别是:钉钉,专有钉钉,浙政钉 钉钉 是阿里巴巴集团专为中小企业打造的沟通和协同的多端平台。 专有钉钉 原名 政务钉钉,有更开放的设计能力、集成能力、更结构化协同产品、更定制化开发平台。支持专有化部署,数据落本地,更安全、客户可对该产品持牌运营、结构化编排,协助构建本地应用中心、提供移动应用全面安全保障体系。 浙政钉 为规范浙政钉整体架构体系,按照统分结合原则,由省政府办公厅统一设计整体工作界面和系统框架,统筹指导全省统建应用建设,各单

一缕南风的博客 2万+

windows sever2019切换Linux内核

安装docker engine后,内核是windows,很多镜像都无法安装使用。 一,在https://github.com/linuxkit/lcow/release 下载最新版本release.zip,我使用了如下版本。 二,新建文件夹C:\Program Files\Linux Containers ,把release.zip(不要解压)放入此文件夹 三,编辑docker配置文件( C:\ProgramData\docker\config\daemon.json) ,电脑中没有该文件,新建一

记录日常疑问 3875

leetcode Word Pattern

map

GadyPu的专栏 487

海康威视工业相机网络配置实战:从MVS软件操作到IP地址规划

本文详细介绍了海康威视工业相机的网络配置实战,从MVS软件操作到IP地址规划。重点讲解了IP设置的重要性、Windows系统下的网络配置步骤、避免IP冲突的技巧,以及MVS软件中的相机IP配置方法。帮助用户快速掌握工业相机的网络连接技术,确保稳定高效的图像采集。

weixin_30296405的博客 485

LeetCode题解:Word Pattern

Given a pattern and a string str, find if str follows the same pattern.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:

追风筝的吃货,汪~ 615

树莓派4B+DroneKit实战:手把手教你用Python控制无人机飞行(附避坑指南)

本文提供了一份详尽的树莓派4B与DroneKit配置实战指南,涵盖从硬件选型、软件环境搭建到Python编程控制无人机的完整流程。文章重点解决了ARM架构下的兼容性问题、MAVLink通信配置及端口管理等常见难题,并附带了实用的避坑指南和代码示例,帮助开发者构建稳定可靠的无人机控制系统。

weixin_29056781的博客 410

EMC诊断技术及电磁兼容理论设计

本文深入探讨了EMC诊断技术,重点在于滤波篇,详细讲解了EMI滤波器的设计、选型、测试及应用注意事项。内容涵盖噪声限值法规、滤波器的法规依据、插入损耗测试以及滤波电容的高频特性。同时,还阐述了噪声源的近场与远场特性,如何快速定位和抑制噪声。通过实例分析,提供了滤波器件和辐射噪声抑制器件的选型策略。

让你爱上电路设计 2162

LeetCode290——Word Pattern

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

代码菌的blog 822

贝叶斯网络在R语言中的应用

本文将介绍如何在R语言中使用贝叶斯网络进行建模和推断,并提供相应的源代码示例。以上就是在R语言中使用贝叶斯网络进行建模和推断的基本步骤。通过构建贝叶斯网络模型并使用相应的函数,我们可以对变量之间的依赖关系进行建模、推断和预测。在建立了贝叶斯网络模型后,我们可以使用数据集来估计变量之间的条件概率。接下来,我们可以使用数据集来构建贝叶斯网络模型。除了进行推断,我们还可以使用贝叶斯网络模型进行预测。一旦我们获得了贝叶斯网络模型和条件概率表,我们就可以使用该模型进行推断。首先,我们需要安装并加载相关的R包。

CodeMaven的博客 1277

Leetcode 算法题24

234. Palindrome Linked List判断一个链表是否左右对称,用O(n)的时间和O(1)的内存我的代码:# Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None clas...

li5226966的博客 283

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

Word Pattern问题及解法

问题描述: Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in

刘天的博客 1325

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Word Pattern 双重映射

Word Pattern Given a pattern and a string str, find if str follows the same pattern. Examples: pattern = "abba", str = "dog cat cat dog" should return true.pattern = "abba", str = "

小人物的草稿本 1187

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

leetcode笔记:Word Pattern

题目的大意是,给出一组模式(pattern)和一个字符串(str),判断字符串是否与模式相匹配,并给出了几个例子。

liyuefeilong的专栏 1947

LeetCode290 Word Pattern 同构字符串

题目要求: Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.Exam

ncst 347

Word Pattern

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

码农少年专栏 333

leetcode | Word Pattern

Given a pattern and a string str, find if str follows the same pattern. Examples: pattern = "abba", str = "dog cat cat dog" should return true.pattern = "abba", str = "dog cat cat fish" 

weizaishouex2010的专栏 1661

LEETCODE 290

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

zj443108444的博客 465

[leetcode] 290. Word Pattern

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

TstsUgeg的博客 404

LeetCode 290 Word Pattern

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

我要加油了,因为我还有很多NB的梦想! 475

​LeetCode刷题实战291:单词规律II

算法的重要性,我就不多说了吧,想去大厂,就必须要经过基础知识和业务逻辑面试+算法面试。所以,为了提高大家的算法能力,这个公众号后续每天带大家做一道算法题,题目就从LeetCode上面选 !...

程序IT圈 382

【leetcode】290. Word Pattern

利用map解决一一对应

小do在努力 2092
上一篇: git 基本操作
下一篇: 234. Palindrome Linked List(判断链表是不是回文的)
左眼皮跳跳~
博客等级 码龄13年 17粉丝 400原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值