会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
xcw0754
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
56
57
58
59
60
61
62
下一页
2014年11月22日
LeetCode Remove Element删除元素
摘要: 1 class Solution { 2 public: 3 int removeElement(int A[], int n, int elem) { 4 int *p=A,*e=&A[n-1]; 5 int i,num=n; 6 for(i=0;i<n;i++){ ...
阅读全文
posted @ 2014-11-22 14:33 xcw0754
阅读(144)
评论(0)
推荐(0)
2014年11月21日
LeetCode Remove Duplicates from Sorted Array删除整型数组中的重复元素并返回剩下元素个数
摘要: 1 class Solution { 2 public: 3 int removeDuplicates(int A[], int n) { 4 int *s=&A[0],*e=&A[0]; //s指向开头第一个,e往后遍历相同的 5 int t,i,j=n; 6 fo...
阅读全文
posted @ 2014-11-21 23:45 xcw0754
阅读(224)
评论(0)
推荐(0)
2014年11月19日
LeetCode Remove Duplicates from Sorted List 删除有序链表中的重复结点
摘要: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne...
阅读全文
posted @ 2014-11-19 12:53 xcw0754
阅读(148)
评论(0)
推荐(0)
2014年11月18日
标准C++中的string类的用法总结
摘要: 转自:http://www.cnblogs.com/xFreedom/archive/2011/05/16/2048037.html(部分修改过了) 相信使用过MFC编程的朋友对CString这个类的印象应该非常深刻吧?的确,MFC中的CString类使用起来真的非常的方便好用。但是如果离开了MF...
阅读全文
posted @ 2014-11-18 22:43 xcw0754
阅读(138)
评论(0)
推荐(0)
LeetCode Valid Parentheses 有效括号
摘要: 1 class Solution { 2 public: 3 void push(char c){ //插入结点 4 struct node *n=new struct node; 5 n->nex=0; 6 n->ch=c; 7 n->pre=las...
阅读全文
posted @ 2014-11-18 22:35 xcw0754
阅读(210)
评论(0)
推荐(0)
2014年11月14日
LeetCode Remove Nth Node From End of List 删除链表的倒数第n个结点
摘要: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne...
阅读全文
posted @ 2014-11-14 22:17 xcw0754
阅读(181)
评论(0)
推荐(0)
2014年11月12日
LeetCode Merge Sorted Array 合并已排序的数组
摘要: 1 void merge(int A[], int m, int B[], int n) { 2 int *a=A,*b=B; 3 int i=0,j=0; 4 if(n==0||m==0){ //针对特殊情况,比如A或B中无元素的情况 5 i...
阅读全文
posted @ 2014-11-12 13:40 xcw0754
阅读(192)
评论(0)
推荐(0)
2014年11月9日
LeetCode Minimum Depth of Binary Tree 找最小深度(返回最小深度)
摘要: 题意:找到离根结点最近的叶子结点的那一层(设同一层上的结点与根结点的距离相等),返回它所在的层数。方法有:1、递归深度搜索2、层次搜索方法一:递归(无优化) 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * i...
阅读全文
posted @ 2014-11-09 21:32 xcw0754
阅读(151)
评论(0)
推荐(0)
2014年11月8日
LeetCode Reverse Integer 反转整数
摘要: 1 class Solution { 2 public: 3 int reverse(int x) { 4 int e,s,num,k=0; 5 num=x; 6 e=0; 7 if(x<0) 8 nu...
阅读全文
posted @ 2014-11-08 22:06 xcw0754
阅读(160)
评论(0)
推荐(0)
LeetCode Count and Say 数数字
摘要: 1 class Solution { 2 public: 3 string countAndSay(int n) { 4 if(n==1) return "1"; 5 string str0="",str1="1"; 6 int i,t,count; 7 ...
阅读全文
posted @ 2014-11-08 22:00 xcw0754
阅读(181)
评论(0)
推荐(0)
上一页
1
···
56
57
58
59
60
61
62
下一页
公告