摘要: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 这个是我的代码,但是超时 class Solution { public: int trailingZeroes(int ... 阅读全文
posted @ 2014-12-30 21:26 程序员小王 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A... 阅读全文
posted @ 2014-12-29 20:28 程序员小王 阅读(156) 评论(0) 推荐(0) 编辑
摘要: Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 这道题挺简单的,不多说了,代码奉上 class Solution { public: string addBinary(string a, s... 阅读全文
posted @ 2014-12-29 13:29 程序员小王 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 1.贝叶斯分类器: 用途:分类,举例:垃圾邮件过滤。 是一种典型的监督算法。需要经过训练才能后续进行分类。 进行贝叶斯分类的时候,最重要的环节是特征的提取,这个将训练或者分类的数据转化成一个特征列表。 优点:速度快。对分类器实际学习状况的解释相对简单。 缺陷:无法处理基于特征组合所产生的变化结果。 2.决策树分类器 决策树从根部开始构造。 根据不同的特征拆分,对决策树的构建的影响是... 阅读全文
posted @ 2014-12-28 22:30 程序员小王 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 这道题的难度不算特别大,主要是对链表技能的考察。 奉上我写的代码: class Solution ... 阅读全文
posted @ 2014-12-28 11:45 程序员小王 阅读(113) 评论(0) 推荐(0) 编辑
摘要: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, return 0. Note: A word is defin... 阅读全文
posted @ 2014-12-27 21:49 程序员小王 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 这道题的题意特别简单,就是对两个二叉树进行比对,判断两个二叉树是否完全相同。拿到这道题,既然和二叉树有关,那么必然是使用递归的。正好再熟悉一下递归,可惜,还是对递归没有太深刻的理解。导致写出来的代码始终未能通过。其实思路特别简单。class Solution {public: bool isS... 阅读全文
posted @ 2014-12-14 18:33 程序员小王 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 题目解题步骤对字符串进行处理,字符小写,去掉多余标点。对空字符串的情况进行判断。建立一个新的字符串对象,存入原字符串翻转后的结果如果这两个字符串相等,那么返回True,否则,返回False。我的答案第1版:class Solution: # @param s, a string # @return ... 阅读全文
posted @ 2014-12-13 16:19 程序员小王 阅读(181) 评论(0) 推荐(0) 编辑
摘要: HappyLeetcode1:Reverse Words in a String题目描述:题目思考:建立一个数组,每个数组存储一个单词。将该数组倒序输出,每输出一个单词后,紧跟着输出一个空格。题目解题代码Pythonclass Solution: # @param s, a string # @re... 阅读全文
posted @ 2014-12-13 16:18 程序员小王 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 建立链表结点的结构体有关链表问题,我折腾了好长时间,总是断断续续的。如果想统一花一点时间攻克,估计也差不多能攻克了,折腾来折腾去,拖延症一犯,到现在也没有完全弄清楚。现在先把自己搞明白的有关链表的内容搞明白。 说起单链表,有以下几个方面的内容需要你会写。 建立单链表。 要想实现对链表的操作,首先的当然是建立链表啦。没有链表怎么进行插入删除查找操作啊。 ... 阅读全文
posted @ 2014-08-31 22:58 程序员小王 阅读(297) 评论(0) 推荐(0) 编辑