-
最长回文子串
描述:给出一个字符串(假设长度最长为1000),求出它的最长回文子串,你可以假定只有一个满足条件的最长回文串。(注:“回文串”是一个正读和反读都一样的字符串) 样例 给出字符串 "abcdzdcab",它的最长回文子串为 "cdzdc"。 class Solution {public: string -
爬楼梯
描述:假设你正在爬楼梯,需要n步你才能到达顶部。但每次你只能爬一步或者两步,你能有多少种不同的方法爬到楼顶部? 样例 比如n=3,1+1+1=1+2=2+1=3,共有3中不同的方法 返回 3 思路:因为根据题上的列子,可以知道n=3时,返回3,可以通过递归的方法,不断返回到n=3 class Sol -
A+B 问题
class Solution {public: int aplusb(int a, int b) { if(a==0)return b; if(b==0)return a; int x1 = a^b; int x2 = (a&b)<<1; return aplusb(x1,x2); }}; -
软件工程test1-Q3【爬楼梯】
class Solution {public: /** * @param n: An integer * @return: An integer */ int climbStairs(int n) { // write your code here int a,b; a=b=1; int c; if -
软件工程test1-Q2【买卖股票的最佳时机】
class Solution {public: /** * @param prices: Given an integer array * @return: Maximum profit */ int maxProfit(vector<int> &prices) { // write your co -
软件工程test1-Q1【删除排序数组中的重复数字】
class Solution {public: /** * @param A: a list of integers * @return : return an integer */ int removeDuplicates(vector<int> &nums) { // write your co