Easy-39

leetcode  242. Valid Anagram

Given two strings s and t, write a function to determine if t is an anagram of s.

For example,
s = "anagram", t = "nagaram", return true.
s = "rat", t = "car", return false.

Note:
You may assume the string contains only lowercase alphabets.

AC:

bool isAnagram(char* s, char* t) {
    int a[26]={0};
    int b[26]={0};
    int len1=strlen(s);
    int len2=strlen(t);
    if(len1!=len2)
    {
        return false;
    }
    for(int i=0;i<len1;i++)
    {
        a[s[i]-'a']++;
    }
    for(int i=0;i<len2;i++)
    {
        b[t[i]-'a']++;
    }
    for(int i=0;i<26;i++)
    {
        if(a[i]!=b[i])
        return false;
    }
    return true;
}


Follow up:
What if the inputs contain unicode characters? How would you adapt your solution to such case?

D:\UserData\Downloads>easy_install pysqlcipher3-1.0.3-py3.7-win32.egg WARNING: The easy_install command is deprecated and will be removed in a future version. Processing pysqlcipher3-1.0.3-py3.7-win32.egg creating c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\pysqlcipher3-1.0.3-py3.7-win32.egg Extracting pysqlcipher3-1.0.3-py3.7-win32.egg to c:\users\admin\appdata\local\programs\python\python39\lib\site-packages Removing pysqlcipher3 1.0.3 from easy-install.pth file Adding pysqlcipher3 1.0.3 to easy-install.pth file Installed c:\users\admin\appdata\local\programs\python\python39\lib\site-packages\pysqlcipher3-1.0.3-py3.7-win32.egg Processing dependencies for pysqlcipher3==1.0.3 Searching for pysqlcipher3==1.0.3 Reading http://rdsource.tp-link.com/pypi/simple/pysqlcipher3/ Downloading http://rdsource.tp-link.com/pypi/packages/pysqlcipher3/1.0.3/pysqlcipher3-1.0.3.tar.gz#sha256=694e5bbb6ece8a064bd55f261e54b9ffbb3af1784afdc4dce4948a0251a8a430 Best match: pysqlcipher3 1.0.3 Processing pysqlcipher3-1.0.3.tar.gz Writing C:\Users\admin\AppData\Local\Temp\easy_install-0hlokiqt\pysqlcipher3-1.0.3\setup.cfg Running pysqlcipher3-1.0.3\setup.py -q bdist_egg --dist-dir C:\Users\admin\AppData\Local\Temp\easy_install-0hlokiqt\pysqlcipher3-1.0.3\egg-dist-tmp-wzot1opu warning: no previously-included files matching &#39;*~&#39; found anywhere in distribution warning: no previously-included files matching &#39;*.pyc&#39; found anywhere in distribution No eggs found in C:\Users\admin\AppData\Local\Temp\easy_install-0hlokiqt\pysqlcipher3-1.0.3\egg-dist-tmp-wzot1opu (setup script problem?) error: The &#39;pysqlcipher3==1.0.3&#39; distribution was not found and is required by the application
最新发布
08-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值