Leetcode PHP題解--D85 242. Valid Anagram
D85 242. Valid Anagram
題目連結
題目分析
判斷給定的兩個單詞是否同構。即,重新排列組合所出現的字母后得到另一個單詞。
思路
拆分成陣列後,排序,再拼起來。判斷是否相同。
最終程式碼
<?php class Solution { /** * @param String $s * @param String $t * @return Boolean */ function isAnagram($s, $t) { $arrs = str_split($s); $arrt = str_split($t); sort($arrs); sort($arrt); return implode($arrs) === implode($arrt); } }
相關推薦
Leetcode PHP題解--D85 242. Valid Anagram
D85 242. Valid Anagram 題目連結 242. Valid Anagram 題目分析 判斷給定的兩個單詞是否同構
[LeetCode&Python] Problem 242. Valid Anagram
Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: s = "anagram", t
242. Valid Anagram(leetcode)
nag only 出現 sum col isa turn solution 簡單 Given two strings s and t, write a function to determine if t is an anagram of s. For example, s
[leetcode]242. Valid Anagram判斷兩個字符串是不是包含相同字符的重排列
思路 har urn pos 兩個 字符串 就是 true etc /* 思路是判斷26個字符在兩個字符串中出現的次數是不是都一樣,如果一樣就返回true。 記住這個方法 */ if (s.length()
[leetcode]242.Valid Anagram
代碼 ase return pre 不一致 charat lee sum function 題目 Given two strings s and t , write a function to determine if t is an anagram of s. Examp
LeetCode-242. Valid Anagram
Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: s = "anagr
Leetcode 242. Valid Anagram
文章作者:Tyan 部落格:noahsnail.com | CSDN | 簡書 1. Description 2. Solution Version 1 class Solution {
[LeetCode] 242. Valid Anagram
題目 Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: s = "anagram", t = "nagara
python leetcode 242. Valid Anagram
class Solution: def isAnagram(self, s, t): """ :type s: str :type t: str :rtype: bool """ dp1=
242. Valid Anagram
repl uml rac have blank ray under tco number https://leetcode.com/problems/valid-anagram/#/description Given two strings s and t, wri
Sort-242. Valid Anagram
input nic question mine nag hat char and span Given two strings s and t, write a function to determine if t is an anagram of s. For exa
242. Valid Anagram(python+cpp)
題目: Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: In
LeetCode刷題Easy篇.Valid Anagram
題目 Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: s = "
Leetcode PHP題解--D81 520. Detect Capital
D81 520. Detect Capital 題目連結 520. Detect Capital 題目分析 給定一個單詞,判斷其使
Leetcode PHP題解--D82 13. Roman to Integer
D82 13. Roman to Integer 題目連結 13. Roman to Integer 題目分析 將給定的羅馬數字轉
Leetcode PHP題解--D83 169. Majority Element
D83 169. Majority Element 題目連結 169. Majority Element 題目分析 給定一個數組,
Leetcode PHP題解--D87 705. Design HashSet
D87 705. Design HashSet 題目連結 705. Design HashSet 題目分析 設計一個雜湊類。 需要
Leetcode PHP題解--D88 696. Count Binary Substrings
D88 696. Count Binary Substrings 題目連結 696. Count Binary Substring
Leetcode PHP題解--D89 653. Two Sum IV
D89 653. Two Sum IV - Input is a BST 題目連結 653. Two Sum IV - Input
Leetcode PHP題解--D90 217. Contains Duplicate
D90 217. Contains Duplicate 題目連結 217. Contains Duplicate 題目分析 返回給