(1)传统的字符串匹配算法:注意这道题中各种特殊情况的返回值。传统字符串匹配就是让目标字符串从第一个字母开始逐个匹配源字符串的每一个字符,直到匹配完全。class Solution {public: int strStr(string haystack, string needle) { ...
分类:
其他好文 时间:
2015-06-01 18:26:18
阅读次数:
112
Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lowercase letters a-z.思路分析:这题主要考察Trie 即前缀树的实现,Trie可以用于字典的压缩存储,可以节省空间,但是不节省时间(和HashSet相比)...
分类:
其他好文 时间:
2015-05-31 14:05:08
阅读次数:
178
Given an array of integers, every element appears three times except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without usi...
分类:
其他好文 时间:
2015-05-31 12:31:13
阅读次数:
118
Runtime Complexity of .NET Generic CollectionI had to implement some data structures for my computational geometry class. Deciding whether to implemen...
分类:
Web程序 时间:
2015-05-31 06:47:30
阅读次数:
228
这个exercise需要完成cnn中的forward pass,cost,error和gradient的计算。需要弄清楚每一层的以上四个步骤的原理,并且要充分利用matlab的矩阵运算。大概把过程总结了一下如下图所示:STEP 1:Implement CNN ObjectiveSTEP 1a: Fo...
分类:
Web程序 时间:
2015-05-30 12:03:11
阅读次数:
220
Implement int sqrt(int x).Compute and return the square root of x. 1 class Solution { 2 public: 3 int mySqrt(int x) { 4 unsigned long long...
分类:
其他好文 时间:
2015-05-29 20:05:20
阅读次数:
114
问题Next Permutation:https://leetcode.com/problems/next-permutation/Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement...
分类:
其他好文 时间:
2015-05-29 18:18:23
阅读次数:
118
Given an array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using ext...
分类:
其他好文 时间:
2015-05-29 18:16:19
阅读次数:
142
Implement Trie (Prefix Tree)问题:Implement a trie withinsert,search, andstartsWithmethods.思路: 前缀树我的代码:class TrieNode { // Initialize your data struc...
分类:
其他好文 时间:
2015-05-29 17:42:12
阅读次数:
114
题目:Implement pow(x,n).代码:class Solution {public: double myPow(double x, int n) { double ret = Solution::positivePow(fabs(x), ...
分类:
其他好文 时间:
2015-05-29 13:27:57
阅读次数:
94