自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

LeoSha的专栏

编程的唯一技巧就是保持单纯!

  • 博客(11)
  • 收藏
  • 关注

原创 Best Time to Buy and Sell Stock

问题描述: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the sto

2015-06-29 21:37:06 679

原创 Balanced Binary Tree

问题描述:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe

2015-06-29 19:44:49 836

原创 Anagrams

问题描述: Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case. 例如:输入为:{abc,bca,123,321,567} 输出为:{abc,bca,123,321} 解决方案:class Sol

2015-06-29 17:19:40 914

原创 Add Two Numbers

问题描述: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as

2015-06-29 16:34:31 689

原创 Add Binary

问题描述: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, string b) { i

2015-06-29 15:49:01 836

原创 3Sum Closest

Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly

2015-06-29 11:23:13 674

原创 3sum

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:•Elements in a triplet (a,b,c) must be in

2015-06-29 10:29:38 782

原创 和为S的连续正数序列

题目: 输入一个正数s,打印出所有和为S的连续正数序列(至少含有两个数)。例如输入15,由于1+2+3+4+5=4+5+6=7+8=15,所以打印出三个结果。void FindContinuousSequence(int sum){ if(sum < 3) return; int small = 1; int big = 2; int middle

2015-06-15 15:44:31 684

原创 旋转数组中查找指定元素

如题,在旋转数组中查找指定元素,考虑到多种情况,网上的方法大部分没有考虑,当low,high,mid三个值相等时的情况。 代码如下:int findAll(int A[],int low,int high,int value)//当三个相等时,查找全部元素的函数。{ for(int i = low;i < high;i++) { if(A[i]==value)

2015-06-14 16:03:32 1285

原创 用C++解决:把数组排成最小的数问题

问题描述: 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印出拼接出的所有数字中最小的一个。例如输入数组{3,32,321},则打印出这3个数字能拍成的最小数字321323。 C++代码:void PrintMinNumber(int* numbers, int length){ if(numbers == NULL || length <= 0)

2015-06-12 20:03:11 1886

原创 二叉树节点间最长距离

//节点结构体struct BinaryTreeNode{ BinaryTreeNode* left = NULL; BinaryTreeNode* right = NULL; int floor = 1;};//查找最大路径,返回路径长度int FindMaxPath(BinaryTreeNode* t){ if

2015-06-03 09:15:24 806

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除