leetcode_242_ValidAnagram高质量C++代码
这道题标签是eazy,可以排序判断字符串相等,但是只击败了33%的C++编程者,博主自然是不甘心的,于是采用统计词频,并且略施小计,一开始先校验长度,这样就击败了99%。:)…
PC's Blog
这道题标签是eazy,可以排序判断字符串相等,但是只击败了33%的C++编程者,博主自然是不甘心的,于是采用统计词频,并且略施小计,一开始先校验长度,这样就击败了99%。:)…
这道题是Google的面试题,参照WigglySortI,本质就是一个坐标映射,只是中位数有等号,映射时候需要小心,博主第一版代码直接用Sort排序,代码击败65.8%,然后参照大牛代码,使用三路快排,速度已经提起来了。和大牛的代码不同的是,大牛采用高大上的宏函数做坐标映射,博主比较笨,理解那个映射公式花了些时间,索性就用了第一版代码的坐标映射,单独写了一个for循环。大牛代码103ms,博主代码102ms,所以坐标映射部分开销是差不多的,可见代码核心还是在三路快排(三指针)上。…
好久没写博客,贡献一份高质量代码。高质量代码其实思路上没什么特别的,只是编程细节上面做了些优化。
Your runtime beats 96.73% of cppsubmissions!…
Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab"
, Return 1
since the …
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in the combination. Note: All numbers …
题意:找出比当前排序大一号的排序,如果当前排序就是最大排序,那么将它重拍成最小排序。…
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of …