![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
模拟
JohnWill_
小白一个,慢慢成长....
展开
-
Pascal's Triangle-帕斯卡三角
题目描述Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]每一层的第i个位置,等于上一层第i-1与第i个位置之和...原创 2018-03-26 11:03:48 · 236 阅读 · 0 评论 -
String to Integer (atoi)
题目描述Implement atoi to convert a string to an integer. 实现代码: class Solution {public: int atoi(const char *str) { string s(str); if (s.empty()) return 0; long int...原创 2018-04-21 16:16:21 · 125 阅读 · 0 评论 -
Reverse Integer(翻转整数)
题目描述Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 click to show spoilers.Have you thought about this? Here are some good questions to ask before cod...原创 2018-04-21 15:15:40 · 229 阅读 · 0 评论 -
ZigZag Conversion 之字形转换
题目描述The string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H NA P L S I...原创 2018-04-20 21:12:14 · 323 阅读 · 0 评论 -
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 ...原创 2018-04-20 08:53:12 · 89 阅读 · 0 评论 -
Roman to Integer
题目描述Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 实现代码: class Solution {public: int val[255]; void init() { ...原创 2018-04-23 15:45:02 · 105 阅读 · 0 评论 -
Integer to Roman (罗马数字转换)
题目描述Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 科普了一下表达方式,理解了就不复杂了。I = 1;V = 5;X = 10;L = 50;C = 100;D = 500;M = 1000;其中每两个阶段的之间有一个减法的...原创 2018-04-23 15:21:57 · 161 阅读 · 0 评论 -
Divide Two Integers
题目描述Divide two integers without using multiplication, division and mod operator. 这道题的要求是在不使用乘法、除法、取模运算的前提下实现两个整数相除。如果溢出,返回MAX_INT。这道题的直接思路是用被除数不断减去除数,直到为0。这种方法的迭代次数是结果的大小,即比如结果为n,算法复杂度是O(n)。可以采用位运算进行...原创 2018-04-17 22:09:54 · 82 阅读 · 0 评论 -
Pascal's Triangle 2
题目描述Given an index k, return the k th row of the Pascal's triangle. For example, given k = 3, Return[1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space?注意边界问题!!!输出第...原创 2018-03-26 15:00:51 · 95 阅读 · 0 评论 -
Palindrome Number回文串数字
题目描述Determine whether an integer is a palindrome. Do this without extra space. 判断一个数字是不是回文串,来回读都是一样的!!!实现代码: class Solution {public: int reverse(int x) { int val=0; wh...原创 2018-04-21 17:15:01 · 133 阅读 · 0 评论