2016年5月26日

171. Excel Sheet Column Number

摘要: A=1,B=2,...,AA=27 思路: 假设字符串为s A-Z代表1-26,就是26进制, 再把A-Z的ACS码-64,就是1-26,然后就是正常的数值运算 26*(s[i]-64)+s[i+1]-64; 阅读全文

posted @ 2016-05-26 00:02 不小的文 阅读(107) 评论(0) 推荐(0) 编辑

2016年5月24日

100. Same Tree

摘要: 判断两个数是否相等。 子问题:两个节点是否相等 两个节点为空,则相等,此时没有左右节点。 不全为空或者值不相等,则不相等。 左节点相等&&右节点相等。 阅读全文

posted @ 2016-05-24 17:55 不小的文 阅读(70) 评论(0) 推荐(0) 编辑

283. Move Zeroes

摘要: 把数组中的0都移到末尾。 void moveZeros(vector<int> nums) { int n=nums.size(); int j=0; for(int i=0;i<n;i++) { if(nums[i]!=0) { nums[j]=0; j++ } } while(j<n) { nu 阅读全文

posted @ 2016-05-24 17:19 不小的文 阅读(100) 评论(0) 推荐(0) 编辑

226. Invert Binary Tree

摘要: Invert a binary tree. to 阅读全文

posted @ 2016-05-24 16:44 不小的文 阅读(70) 评论(0) 推荐(0) 编辑

104. Maximum Depth of Binary Tree

摘要: 找二叉树最长的路径。 class solution public: int maxDepth(TreeNode* root) { if(root==NULL) return 0; else return 1+max(maxDepth(root->left),maxDepth(root->right) 阅读全文

posted @ 2016-05-24 16:40 不小的文 阅读(77) 评论(0) 推荐(0) 编辑

258.Add Digits

摘要: 给定正整数,如12,各位相加,直到只剩一个数字,结果为3。 class solution public: int addDigits(int num) { if(num<10) return num; else { while(num>9) { int sum = 0; sum = sum + nu 阅读全文

posted @ 2016-05-24 16:09 不小的文 阅读(82) 评论(0) 推荐(0) 编辑

292.Nim Game

摘要: 一堆石头,轮流拿走1-3个,拿到最后一个石头的赢。每次游戏我先开始,给定石头个数N,判断是否我是否能赢。 class Solution {public: bool canWinNim(int n) { return N%4==0? false:true; }}; 思路:当只有4个石头的时候,谁先拿谁 阅读全文

posted @ 2016-05-24 15:51 不小的文 阅读(116) 评论(0) 推荐(0) 编辑

2016年4月29日

172. Factorial Trailing Zeroes

摘要: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 计算n的阶乘后面有多少0 思路:就是看能被多少个 阅读全文

posted @ 2016-04-29 15:08 不小的文 阅读(92) 评论(0) 推荐(0) 编辑

2016年4月28日

条件高斯分布

摘要: 主要介绍条件高斯分布的求解方法,为之后理解正则化打好基础。 阅读全文

posted @ 2016-04-28 15:19 不小的文 阅读(867) 评论(0) 推荐(0) 编辑

2016年3月18日

【LeetCode 110】Merge Two Sorted Lists

摘要: 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. 将两个有序链表合 阅读全文

posted @ 2016-03-18 14:53 不小的文 阅读(108) 评论(0) 推荐(0) 编辑

导航