摘要:
mplement regular expression matching with support for'.'and'*'. 阅读全文
摘要:
Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack. 阅读全文
摘要:
回文的题经常出现在算法题中,下面总结了leetcode出现的6个关于回文的题目。 1.Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring case 阅读全文
摘要:
1 class Solution { 2 public: 3 ListNode *removeNthFromEnd(ListNode *head, int n) { 4 5 ListNode* fake = new ListNode(-1); 6 fake->next = head; 7 ListNode* p = fake... 阅读全文
摘要:
Given a list, rotate the list to the right by kplaces, where k is non-negative. For example:Given1->2->3->4->5->NULLand k =2,return4->5->1->2->3->NULL 阅读全文
摘要:
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 阅读全文
摘要:
面试中经常会碰到单链表的排序,主要是插入排序和归并排序 插入排序: 归并排序: 阅读全文
摘要:
ListNode* reverseList(ListNode* head) { if (head == nullptr || head->next == nullptr) return head; ListNode* dummy = new ListNode(-1); dummy->next = head; ListNode* p = head->next; ... 阅读全文
摘要:
由于C++支持函数重载,在编译函数代码的时候会加上参数类型的信息,而C编译只有函数名信息,导致C++直接调用C代码在链接的时候会出现函数未定义的问题。解决这种问题有两种方法。方法一:在写C代码的时候考虑到C++可能会调用这些函数,增加extern “C”;方法二:如果C++要调用的C代码没有考虑到这 阅读全文
摘要:
BST的查找非常简单,插入是基于查找进行的,有一点需要注意的是插入一定是称为叶子节点的孩子节点。删除稍微麻烦一点,要分情况讨论,当要删除的节点有两个孩子节点时,首先寻找要删除节点p的左子树的最大的节点s,然后交换p和s的数值,调整s父节点的指向,删除s节点。 阅读全文