一天一道算法题
文章平均质量分 74
Strugoogle
这个作者很懒,什么都没留下…
展开
-
【LEETCODE】Implement strStr().
if(*haystack=='\0'||*needle=='\0') return -1; char *p1=haystack;char *p2=needle;int k=0;char *temp=haystack; while(*p1!='\0'){ if(*p1==*p2){ temp=p1;原创 2014-11-24 22:25:38 · 547 阅读 · 0 评论 -
【LEETCODE】Reverse Words in a String
class Solution {public: void reverseWords(string &s) { int length=s.length(); string s1="";string s2=""; int k1=length; int k2=0; int flag=0;原创 2014-09-11 10:04:51 · 665 阅读 · 0 评论 -
【LEETCODE】Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the larges原创 2014-12-02 10:17:53 · 524 阅读 · 0 评论 -
『lintcode』第k的元素
在数组中找到第k大的元素注意你可以交换数组中的元素的位置样例给出数组[9,3,2,4,8],第三大的元素是4给出数组 [1,2,3,4,5],第一大的元素是5,第二大的元素是4,第三大的元素是3,以此类推code:class Solution {public: /* * param k : description of k原创 2015-03-23 12:13:26 · 448 阅读 · 0 评论