Travis build: 429
This commit is contained in:
@ -890,14 +890,14 @@
|
||||
"type": "snippetListing",
|
||||
"title": "is_anagram",
|
||||
"attributes": {
|
||||
"text": "Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).\n\nUse `s.replace()` to remove spaces from both strings.\nCompare the lengths of the two strings, return `False` if they are not equal.\nUse `sorted()` on both strings and compare the results.\n\n",
|
||||
"text": "Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).\n\nUse `isalnum()` to filter out non-alphanumeric characters, `lower()` to transform each character to lowercase.\nUse `collections.Counter` to count the resulting characters for each string and compare the results.\n\n",
|
||||
"tags": [
|
||||
"string",
|
||||
"intermediate"
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "efdcecce589a3812218ede260f156888eb8544ccf85eab35d1885689668292e8"
|
||||
"hash": "15833b3a98e905cf4cbac346028c5e6b5560d3b968800b94548e77a77098b7cc"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@ -1413,10 +1413,10 @@
|
||||
"type": "snippet",
|
||||
"attributes": {
|
||||
"fileName": "is_anagram.md",
|
||||
"text": "Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).\n\nUse `s.replace()` to remove spaces from both strings.\nCompare the lengths of the two strings, return `False` if they are not equal.\nUse `sorted()` on both strings and compare the results.\n\n",
|
||||
"text": "Checks if a string is an anagram of another string (case-insensitive, ignores spaces, punctuation and special characters).\n\nUse `isalnum()` to filter out non-alphanumeric characters, `lower()` to transform each character to lowercase.\nUse `collections.Counter` to count the resulting characters for each string and compare the results.\n\n",
|
||||
"codeBlocks": {
|
||||
"code": "def is_anagram(s1, s2):\n _str1, _str2 = s1.replace(\" \", \"\"), s2.replace(\" \", \"\")\n return False if len(_str1) != len(_str2) else sorted(_str1.lower()) == sorted(_str2.lower())",
|
||||
"example": "is_anagram(\"anagram\", \"Nag a ram\") # True"
|
||||
"code": "from collections import Counter\n\ndef is_anagram(s1, s2):\n return Counter(\n c.lower() for c in s1 if c.isalnum()\n ) == Counter(\n c.lower() for c in s2 if c.isalnum()\n )",
|
||||
"example": "is_anagram(\"#anagram\", \"Nag a ram!\") # True"
|
||||
},
|
||||
"tags": [
|
||||
"string",
|
||||
@ -1424,11 +1424,11 @@
|
||||
]
|
||||
},
|
||||
"meta": {
|
||||
"hash": "efdcecce589a3812218ede260f156888eb8544ccf85eab35d1885689668292e8",
|
||||
"hash": "15833b3a98e905cf4cbac346028c5e6b5560d3b968800b94548e77a77098b7cc",
|
||||
"firstSeen": "1538389049",
|
||||
"lastUpdated": "1578049045",
|
||||
"updateCount": 8,
|
||||
"authorCount": 4
|
||||
"lastUpdated": "1584622237",
|
||||
"updateCount": 10,
|
||||
"authorCount": 5
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user