![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
ggsdddu
这个作者很懒,什么都没留下…
展开
-
LeetCode Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a原创 2015-01-23 16:44:17 · 236 阅读 · 0 评论 -
Plus One
class Solution {public: vector plusOne(vector &digits) { vector::reverse_iterator it = digits.rbegin(); int c = 1; //进位标志 for( ; it != digits.rend(); it++){ *i原创 2015-02-05 17:16:17 · 209 阅读 · 0 评论 -
Merge Sorted Array
class Solution {public: void merge(int A[], int m, int B[], int n) { int idx = (m+n-1); int ai = m-1, bi = n-1; while(ai>=0 && bi>=0) { A[ai]>=B[bi] ? A[idx--]原创 2015-02-06 11:02:16 · 192 阅读 · 0 评论 -
Pascal's Triangle II
class Solution {public: vector getRow(int rowIndex) { //注意0对应1个元素, 1对应2个元素, 。。。。。。 vector upper; upper.push_back(1); if(rowIndex==0) {return upper;}原创 2015-02-06 09:18:18 · 195 阅读 · 0 评论 -
removeDuplicateFromArray
数组输出函数:void outputArray(int a[], int length) { //函数参数必须包含length(数组的长度),因为在函数内部sizeof(a)不是数组存储空间的大小而是头指针a的存储空间的大小 for(int i=0; i<length; i++){ cout<<a[i]<<" "; } cout<<endl;}从数组中删除重复元素,并返回原创 2015-02-03 15:50:22 · 274 阅读 · 0 评论 -
Valid Parentheses
class Solution {public: bool isValid(string s) { int length = s.length(); if(length==0) { return true; } stack charStack; while(length){ if(s[length-1]原创 2015-02-05 19:39:32 · 215 阅读 · 0 评论 -
Pascal's Triangle
class Solution {public: vector > generate(int numRows) { vector> result; //当numRows=0时,返回空的三角; if(numRows==0) return result; vector upper; upper.push_back(原创 2015-02-05 14:55:17 · 190 阅读 · 0 评论 -
Search in Rotated Sorted Array
class Solution {public: int search(int A[], int n, int target) { int first = 0, last = n - 1; while(first <= last){ int mid = (first + last)/2;原创 2015-02-05 11:19:32 · 246 阅读 · 0 评论 -
数组初始化
一直以为如果定义数组如下:int a[5] = {0};则a的内容为0,0,0,0,0;因此如果定义int a[5] = {1};则a的内容为1,1,1,1,1,这种想当然是错误的,因该是1,0,0,0,0;以为数组初始化的个数如果小于定义的数组大小,则剩下的元素初始化为0。有次可以类推bool ,char等数组的初始化。原创 2015-03-09 16:39:57 · 270 阅读 · 0 评论