会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
程序员三木
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
6
7
8
9
10
11
12
13
14
···
26
下一页
2014年8月2日
String to Integer (atoi)
摘要: 问题:将字符窜转换成数字分析:感觉题目不难,但是细节很多,容易想不到1.数字前面有空格 如s=“ 123456”2.数字前出现了不必要或多于的字符导致数字认证错误,输出0 如s=“ b1234” ,s=“ ++1233” , s=“ +-1121”3.数字中出现了不必要的字符,返回字符前的数字...
阅读全文
posted @ 2014-08-02 11:03 calmound
阅读(7895)
评论(0)
推荐(0)
2014年8月1日
Remove Element
摘要: 问题:删除数组中和elem相等的元素,并且返回新数组大小。英语不好。。。读错题了。。class Solution {public: int removeElement(int A[], int n, int elem) { int i,j; for(int i=0;...
阅读全文
posted @ 2014-08-01 22:03 calmound
阅读(1030)
评论(0)
推荐(1)
Roman to Integer
摘要: 问题:罗马数字变为整数class Solution {public: int romanToInt(string s) { char c[10][10][10]={{"0","I","II","III","IV","V","VI","VII","VIII","IX"},{"0"...
阅读全文
posted @ 2014-08-01 21:41 calmound
阅读(908)
评论(0)
推荐(0)
Search Insert Position
摘要: 问题:一个数应该插入到有序数组的哪个位置class Solution {public: int searchInsert(int A[], int n, int target) { int i; for(i=0;i<n;i++) if(target<=A[i]) b...
阅读全文
posted @ 2014-08-01 21:26 calmound
阅读(132)
评论(0)
推荐(0)
Same Tree
摘要: 问题:判断两棵二叉树是否相等class Solution {public: bool isSameTree(TreeNode *p, TreeNode *q) { if(!( (p && q && p->val==q->val) || (p==NULL && q==NULL)))...
阅读全文
posted @ 2014-08-01 21:15 calmound
阅读(649)
评论(0)
推荐(0)
Merge Sorted Array
摘要: 问题:将B按顺序合并到A上分析:插入排序,注意A数组为空class Solution{public: void merge(int A[], int m, int B[], int n) { int i,j; if(m==0) { ...
阅读全文
posted @ 2014-08-01 20:59 calmound
阅读(447)
评论(0)
推荐(0)
Maximum Depth of Binary Tree
摘要: 问题:二叉树的最深深度class Solution{public: void dfs(TreeNode *root,int step,int &MAX) { if(root==NULL) { if(MAXleft,step+1); ...
阅读全文
posted @ 2014-08-01 20:41 calmound
阅读(451)
评论(0)
推荐(0)
Reverse Integer
摘要: 问题:翻转数字分析:注意初始化class Solution {public: int reverse(int x) { int y=0; while(x) { y=(y*10)+x%10; x/=10; ...
阅读全文
posted @ 2014-08-01 18:32 calmound
阅读(104)
评论(0)
推荐(0)
Single Number
摘要: 问题:给你一组数一个数字出现一次,其他的数字出现两次,找出那个出现一次的数字分析:相同数字异或为0,所以将所有数字都异或后剩下的就是出现一次的数class Solution {public: int singleNumber(int A[], int n) { int sum=0...
阅读全文
posted @ 2014-08-01 18:18 calmound
阅读(132)
评论(0)
推荐(0)
Integer to Roman
摘要: 问题:将数字转化为罗马数字分析:将所有的数字打表出来class Solution {public: string intToRoman(int num) { char c[10][10][10]={{"0","I","II","III","IV","V","VI","VII","...
阅读全文
posted @ 2014-08-01 09:18 calmound
阅读(1057)
评论(0)
推荐(0)
上一页
1
···
6
7
8
9
10
11
12
13
14
···
26
下一页