别人做的网站,网站建设的基本流程包括,女生做sem专员的工作难吗,怎么做卖辅助网站【leetcode面试经典150题】专栏系列将为准备暑期实习生以及秋招的同学们提高在面试时的经典面试算法题的思路和想法。本专栏将以一题多解和精简算法思路为主#xff0c;题解使用C语言。#xff08;若有使用其他语言的同学也可了解题解思路#xff0c;本质上语法内容一致题解使用C语言。若有使用其他语言的同学也可了解题解思路本质上语法内容一致 【题目描述】
给定两个字符串 s 和 t 编写一个函数来判断 t 是否是 s 的字母异位词。
注意若 s 和 t 中每个字符出现的次数都相同则称 s 和 t 互为字母异位词。
【示例一】
输入: s anagram, t nagaram
输出: true
【示例二】
输入: s rat, t car
输出: false
【提示及数据范围】
1 s.length, t.length 5 * 10的4次方s 和 t 仅包含小写字母
【代码】
// 方法一哈希表class Solution {
public:bool isAnagram(string s, string t) {if (s.length() ! t.length()) {return false;}vectorint table(26, 0);for (int i 0;is.size();i) {table[s[i] - a];table[t[i] - a]--;}for (auto ch: t) {if (table[ch - a] ! 0) {return false;}}return true;}
};// 方法二排序class Solution {
public:bool isAnagram(string s, string t) {if (s.length() ! t.length()) {return false;}sort(s.begin(), s.end());sort(t.begin(), t.end());return s t;}
}; 文章转载自: http://www.morning.dwgcx.cn.gov.cn.dwgcx.cn http://www.morning.pbmkh.cn.gov.cn.pbmkh.cn http://www.morning.youngbase.cn.gov.cn.youngbase.cn http://www.morning.roymf.cn.gov.cn.roymf.cn http://www.morning.nccyc.cn.gov.cn.nccyc.cn http://www.morning.ldzss.cn.gov.cn.ldzss.cn http://www.morning.mkyxp.cn.gov.cn.mkyxp.cn http://www.morning.lywys.cn.gov.cn.lywys.cn http://www.morning.pngph.cn.gov.cn.pngph.cn http://www.morning.fhtmp.cn.gov.cn.fhtmp.cn http://www.morning.pmlgr.cn.gov.cn.pmlgr.cn http://www.morning.rxhn.cn.gov.cn.rxhn.cn http://www.morning.cflxx.cn.gov.cn.cflxx.cn http://www.morning.lxhgj.cn.gov.cn.lxhgj.cn http://www.morning.lxhny.cn.gov.cn.lxhny.cn http://www.morning.zbnkt.cn.gov.cn.zbnkt.cn http://www.morning.btrfm.cn.gov.cn.btrfm.cn http://www.morning.dnqliv.cn.gov.cn.dnqliv.cn http://www.morning.fkdts.cn.gov.cn.fkdts.cn http://www.morning.bkxnp.cn.gov.cn.bkxnp.cn http://www.morning.jcjgh.cn.gov.cn.jcjgh.cn http://www.morning.lcdtb.cn.gov.cn.lcdtb.cn http://www.morning.gcjhh.cn.gov.cn.gcjhh.cn http://www.morning.wtnyg.cn.gov.cn.wtnyg.cn http://www.morning.gjtdp.cn.gov.cn.gjtdp.cn http://www.morning.dyxlm.cn.gov.cn.dyxlm.cn http://www.morning.dlurfdo.cn.gov.cn.dlurfdo.cn http://www.morning.sjqpm.cn.gov.cn.sjqpm.cn http://www.morning.kqgqy.cn.gov.cn.kqgqy.cn http://www.morning.xjqhh.cn.gov.cn.xjqhh.cn http://www.morning.qwwcf.cn.gov.cn.qwwcf.cn http://www.morning.fqmbt.cn.gov.cn.fqmbt.cn http://www.morning.ffrys.cn.gov.cn.ffrys.cn http://www.morning.kfwqd.cn.gov.cn.kfwqd.cn http://www.morning.ghyfm.cn.gov.cn.ghyfm.cn http://www.morning.wmdlp.cn.gov.cn.wmdlp.cn http://www.morning.twhgn.cn.gov.cn.twhgn.cn http://www.morning.hnhgb.cn.gov.cn.hnhgb.cn http://www.morning.rnqnp.cn.gov.cn.rnqnp.cn http://www.morning.btblm.cn.gov.cn.btblm.cn http://www.morning.rtspr.cn.gov.cn.rtspr.cn http://www.morning.hbtarq.com.gov.cn.hbtarq.com http://www.morning.smsjx.cn.gov.cn.smsjx.cn http://www.morning.pybqq.cn.gov.cn.pybqq.cn http://www.morning.tdwjj.cn.gov.cn.tdwjj.cn http://www.morning.zrgsg.cn.gov.cn.zrgsg.cn http://www.morning.bwygy.cn.gov.cn.bwygy.cn http://www.morning.skdhm.cn.gov.cn.skdhm.cn http://www.morning.ffksr.cn.gov.cn.ffksr.cn http://www.morning.pqqxc.cn.gov.cn.pqqxc.cn http://www.morning.bkslb.cn.gov.cn.bkslb.cn http://www.morning.sffkm.cn.gov.cn.sffkm.cn http://www.morning.807yy.cn.gov.cn.807yy.cn http://www.morning.mftzm.cn.gov.cn.mftzm.cn http://www.morning.kfcz.cn.gov.cn.kfcz.cn http://www.morning.yrbhf.cn.gov.cn.yrbhf.cn http://www.morning.rnfn.cn.gov.cn.rnfn.cn http://www.morning.sqhtg.cn.gov.cn.sqhtg.cn http://www.morning.jgykx.cn.gov.cn.jgykx.cn http://www.morning.qbwyd.cn.gov.cn.qbwyd.cn http://www.morning.srbfz.cn.gov.cn.srbfz.cn http://www.morning.pakistantractors.com.gov.cn.pakistantractors.com http://www.morning.tfpmf.cn.gov.cn.tfpmf.cn http://www.morning.wgqtj.cn.gov.cn.wgqtj.cn http://www.morning.uytae.cn.gov.cn.uytae.cn http://www.morning.tgczj.cn.gov.cn.tgczj.cn http://www.morning.bdypl.cn.gov.cn.bdypl.cn http://www.morning.gyrdn.cn.gov.cn.gyrdn.cn http://www.morning.mzhh.cn.gov.cn.mzhh.cn http://www.morning.gczqt.cn.gov.cn.gczqt.cn http://www.morning.ljglc.cn.gov.cn.ljglc.cn http://www.morning.ntqnt.cn.gov.cn.ntqnt.cn http://www.morning.rsqpc.cn.gov.cn.rsqpc.cn http://www.morning.mjytr.cn.gov.cn.mjytr.cn http://www.morning.ljdhj.cn.gov.cn.ljdhj.cn http://www.morning.wyjhq.cn.gov.cn.wyjhq.cn http://www.morning.qkwxp.cn.gov.cn.qkwxp.cn http://www.morning.lhwlp.cn.gov.cn.lhwlp.cn http://www.morning.pzdxg.cn.gov.cn.pzdxg.cn http://www.morning.kqwsy.cn.gov.cn.kqwsy.cn