最新 最热

leetcode 2 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. Ad...

2019-01-18
1

[LeetCode]Reverse Integer题解[LeetCode]Reverse Integer题解

要点 本题考查的是整数相加的溢出处理,检查溢出有这么几种办法: – 两个正数数相加得到负数,或者两个负数相加得到正数,但某些编译器溢出或优化的方式不一样 – 对于正数,如果最大整数减去一个数小于另一个数,或者对于负数,...

2018-09-04
1

浅谈String模块ascii_letters和digits

本文介绍string模块ascii_letters和digits方法,其中ascii_letters是生成所有字母,从a-z和A-Z,digits是生成所有数字0-9.示例如下:In [2]: chars = string.ascii_letters + string.digitsIn [3]: print(c......

2018-05-04
2

Leetcode 2 Add Two Numbers

题目没有说清楚,trick挺多,考察细心程度的水题吧。 You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their n......

2018-01-12
1

Leetcode 7 Reverse Integer

Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321Easy,没什么好说的注意负数和溢出的情况class Solution {public: int reverse(...

2018-01-12
1

Leetcode 66 Plus One

Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the he...

2018-01-12
1

Leetcode 202 Happy Number

Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, repla...

2018-01-12
1

Leetcode 299. Bulls and Cows

You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your fr...

2018-01-12
2

[LeetCode] 129. Sum Root to Leaf Numbers

该文是关于二叉树的问题,给定一个代表数字的树,需要求出从根结点到叶子结点的所有路径的和。和Path Sum II类似,只不过需要累加的是每个路径代表的数字。通过递归的方式,对每个结点进行遍历,如果该结点有左右子结点,则递归...

2018-01-03
1

LWC 61:738. Monotone Increasing Digits

该文讲述了如何利用单调栈实现一个高效的算法,求解输入整数N的最大单调递增数字。该算法的时间复杂度为O(n),其中n是输入整数N的位数。该算法利用了单调栈的特性:当从左到右扫描数组时,如果栈顶元素等于当前遍历的元素,那...

2018-01-02
1