摘要:
题目: Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 题意: 不用乘号、除号、取模运算来模拟除法。 分析: 一开始每回减去一次除数,这样会超时,优化是减去除数*2^n,用左移运算可以实现每次翻2倍. c... 阅读全文
摘要:
题目: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 题意: 将k个已排好序的链表合并为一个非下降排序的链表。 思路: 将每个链表的表头元素取出来,建立一个小顶堆,因为k个链表中都排好序了,因此每次取堆顶的元素就是k个链表中的最小... 阅读全文
摘要:
题目:Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding eleme... 阅读全文
摘要:
题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 大意是:从所给的字符串s中找出其... 阅读全文