237.删除链表中的节点
题目链接
class Solution {
public:
void deleteNode(ListNode* node) {
*node = *(node -> next);
}
};
242.有效的字母异位词
题目链接
class Solution {
public:
bool isAnagram(string s, string t) {
ios::sync_with_stdio(0);
int *cnt = new int[26]{0};
if(s.size()!=t.size())return false;
for(auto i : s)cnt[i-'a']++;
for(auto i : t)if(--cnt[i-'a'] < 0)return false;
delete []cnt;
return true;
}
};

本文介绍了一种高效删除链表中指定节点的方法,通过原地覆盖节点值来实现,避免了额外的空间开销。同时,探讨了有效的字母异位词判断算法,通过对两个字符串的字符频率进行对比,快速确定是否为异位词。

被折叠的 条评论
为什么被折叠?



