
数学规律
文章平均质量分 50
chuandalishuo
这个作者很懒,什么都没留下…
展开
-
6. ZigZag Conversion
1. Java In-place solution: public class Solution { public String convert(String s, int numRows) { if(numRows=s.length()) return s; StringBuilder sb = new StringBuilder();原创 2016-03-02 15:40:48 · 214 阅读 · 0 评论 -
7. Reverse Integer
1. Java 2. Python class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ flag=1 if x<0: x=x*(-1)原创 2016-03-02 16:39:52 · 187 阅读 · 0 评论 -
9. Palindrome Number
1. Java public class Solution { public boolean isPalindrome(int x) { if(x<0) return false; return x==reverse(x); } public int reverse(int x) { long sum=0;原创 2016-03-08 04:35:26 · 251 阅读 · 0 评论 -
29. Divide Two Integers
题目: Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. Java public class Solution { public int divide(int dividend, int divisor) {原创 2016-06-16 00:27:15 · 204 阅读 · 0 评论 -
172. Factorial Trailing Zeroes
题目: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 思路:每包含一个5,结尾就有一个0. 25=5x5 算两个5,125=5x5x5算三个5. Java:原创 2016-09-21 13:33:44 · 153 阅读 · 0 评论 -
166. Fraction to Recurring Decimal
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses.原创 2016-09-30 05:15:58 · 157 阅读 · 0 评论 -
223. Rectangle Area
Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined by its bottom left corner and top right corner as shown in the figure. Assume that the tota原创 2016-10-27 07:48:56 · 182 阅读 · 0 评论 -
204. Count Primes
Description: Count the number of prime numbers less than a non-negative number, n. 思路: 从前向后扫描,第一次遇到没标记的应该是没有因子的质数。然后把后面所有这个质数的倍数都标记了。 public int countPrimes(int n) { if(n<2) retur原创 2016-10-21 08:54:44 · 155 阅读 · 0 评论 -
371. Sum of Two Integers
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example: Given a = 1 and b = 2, return 3. 思路:a^b异或等于无进位的加法,(a&b) 解法一: public class Solution {原创 2016-11-01 00:15:57 · 162 阅读 · 0 评论