上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 29 下一页

翻转子串

摘要: 题目描述 假定我们都知道非常高效的算法来检查一个单词是否为其他字符串的子串。请将这个算法编写成一个函数,给定两个字符串s1和s2,请编写代码检查s2是否为s1旋转而成,要求只能调用一次检查子串的函数。 给定两个字符串s1,s2,请返回bool值代表s2是否由s1旋转而成。字符串中字符为英文字母和空格 阅读全文
posted @ 2017-04-18 20:54 123_123 阅读(71) 评论(0) 推荐(0) 编辑

unique-paths

摘要: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2017-04-18 00:37 123_123 阅读(93) 评论(0) 推荐(0) 编辑

evaluate-reverse-polish-notation

摘要: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are+,-,*,/. Each operand may be an integer or another expre 阅读全文
posted @ 2017-04-17 21:53 123_123 阅读(84) 评论(0) 推荐(0) 编辑

按之字形顺序打印二叉树

摘要: 题目描述 请实现一个函数按照之字形打印二叉树,即第一行按照从左到右的顺序打印,第二层按照从右至左的顺序打印,第三行按照从左到右的顺序打印,其他行以此类推。 /* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *ri 阅读全文
posted @ 2017-04-09 00:28 123_123 阅读(101) 评论(0) 推荐(0) 编辑

删除链表中重复的结点

摘要: 题目描述 在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针。 例如,链表1->2->3->3->4->4->5 处理后为 1->2->5 /* struct ListNode { int val; struct ListNode *next; ListN 阅读全文
posted @ 2017-04-08 23:45 123_123 阅读(100) 评论(0) 推荐(0) 编辑

字符流中第一个不重复的字符

摘要: 题目描述 请实现一个函数用来找出字符流中第一个只出现一次的字符。例如,当从字符流中只读出前两个字符"go"时,第一个只出现一次的字符是"g"。当从该字符流中读出前六个字符“google"时,第一个只出现一次的字符是"l"。 输出描述: 如果当前字符流没有存在出现一次的字符,返回#字符。 class 阅读全文
posted @ 2017-04-08 23:25 123_123 阅读(89) 评论(0) 推荐(0) 编辑

数组中重复的数字

摘要: 题目描述 在一个长度为n的数组里的所有数字都在0到n-1的范围内。 数组中某些数字是重复的,但不知道有几个数字是重复的。也不知道每个数字重复几次。请找出数组中任意一个重复的数字。 例如,如果输入长度为7的数组{2,3,1,0,2,5,3},那么对应的输出是重复的数字2或者3。 //思路分析,使用ha 阅读全文
posted @ 2017-04-08 22:36 123_123 阅读(112) 评论(0) 推荐(0) 编辑

不用加减乘除做加法

摘要: class Solution { public: int Add(int num1, int num2) { int nOne = 0; int nTwo = 0; do{ nOne = num1 ^ num2; //异或 nTwo = (num... 阅读全文
posted @ 2017-04-08 21:56 123_123 阅读(83) 评论(0) 推荐(0) 编辑

数组中只出现一次的数字

摘要: 题目描述 一个整型数组里除了两个数字之外,其他的数字都出现了两次。请写程序找出这两个只出现一次的数字。 class Solution { public: void FindNumsAppearOnce(vector<int> data,int* num1,int *num2) { if(data.s 阅读全文
posted @ 2017-04-08 16:48 123_123 阅读(95) 评论(0) 推荐(0) 编辑

把数组排成最小的数

摘要: 题目描述 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323。 class Solution { public: string PrintMinNumber(vector<in 阅读全文
posted @ 2017-04-07 15:35 123_123 阅读(94) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 29 下一页