LeetCode-242

Links:https://leetcode.com/problems/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.

题意:就是判断字符串s和t是变位词。

思路1:排序判断相等。(n*logn + n)

思路2:计数判断相等。(2*n + 26)(未做…)

 

【LeetCode】242. Valid Anagram
Tagged on:
0 0 投票数
Article Rating
订阅评论
提醒

0 评论
最新
最旧 最多投票
内联反馈
查看所有评论