大道至简

人生苦短,我用Python.

LeetCode-Alg-970-Powerful-Integers

LeetCode-Alg-970-Powerful-Integers

1、题目 Given two positive integers x and y, an integer is powerful if it is equal to x^i + y^j for some integers i >= 0 and j >= 0. Return a list of all powerful integers that have value less...

LeetCode-Alg-860-Lemonade-Change

LeetCode-Alg-860-Lemonade-Change

1、题目 At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills). Each customer will only buy one le...

LeetCode-Alg-400-Nth-Digit

LeetCode-Alg-400-Nth-Digit

1、题目 Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, … Note: n is positive and will fit within the range of a 32-bit signed integer (n < 231). Example 1...

LeetCode-Alg-1025-Divisor Game

LeetCode-Alg-1025-Divisor Game

1、题目 Alice and Bob take turns playing a game, with Alice starting first. Initially, there is a number N on the chalkboard. On each player’s turn, that player makes a move consisting of: Choosin...

LeetCode-Alg-285-Add Digits

LeetCode-Alg-285-Add Digits

1、题目 Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. Example: Input: 38 Output: 2 Explanation: The process is like: 3 + 8 = 11, 1 + 1 = 2. ...

LeetCode-Alg-171-Excel Sheet Column Number

LeetCode-Alg-171-Excel Sheet Column Number

1、题目 Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ... Example 1: I...

LeetCode-Alg-168-Excel Sheet Column Title

LeetCode-Alg-168-Excel Sheet Column Title

1、题目 Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA ...

LeetCode-Alg-784-Letter Case Permutation

LeetCode-Alg-784-Letter Case Permutation

1、题目 Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create. Examples: Input: S...

位运算实现加法

位运算实现加法

在计算机的底层使用位运算计算加法,对于减法运算使用其补码转成加法运算的形式;假设不考虑进位,计算两个一位数的加法 1 + 1 = 0 向上进了一个1 1 + 0 = 1 0 + 1 = 1 0 + 0 = 0 从上面的计算结果可以看出,可以使用异或运算来代替+ 1 ^ 1 = 0 1 ^ 0 = 1 0 ^ 1 = 1 0 ^ 0 = 0 这样就完成了简单的一位数加法,但是进行两...

LeetCode-Alg-1022-Sum of Root To Leaf Binary Numbers

LeetCode-Alg-1022-Sum of Root To Leaf Binary Numbers

1、题目 Given a binary tree, each node has value 0 or 1. Each root-to-leaf path represents a binary number starting with the most significant bit. For example, if the path is 0 -> 1 -> 1 ->...