leetcode
zhangyuming010
这个作者很懒,什么都没留下…
展开
-
【题解】leetcode_Word Frequency
看到最近leetcode出了shell编程训练题,有兴趣做了一下,发现还是蛮难的,提供个参考答案,希望发现更好的shell代码的同学能回复哈。 sed -e "s/[ ]*$//g" words.txt | sed -e "s/^[ ]*//g" | sed 's/\s\+/\n/g' | sort | uniq -c | sort -k1nr |原创 2015-03-22 22:45:04 · 641 阅读 · 0 评论 -
【题解】Binary Tree Right Side View
这道leetcode最新出的题,貌似也不是很难,用广度优先搜索即可,参考代码如下。 class Solution { public: vector rightSideView(TreeNode *root) { vector answer; queue queue, temp_queue; TreeNode * front = 0; if (NULL =原创 2015-04-03 23:47:38 · 533 阅读 · 0 评论 -
【题解】Bitwise AND of Numbers Range
这道题是leetcode上新出的题目,有兴趣做了一下,轻松通过,具体代码如下所示 class Solution { public: int rangeBitwiseAnd(int m, int n) { stack m_stack, n_stack; int one_num = 0; int answer = 0; if (m == n) {原创 2015-04-17 09:31:06 · 582 阅读 · 0 评论