- 博客(25)
- 收藏
- 关注
原创 lintcode/leetcode由易至难第22题:Complex Number Multiplication
Problem:Given two strings representing two complex numbers.You need to return a string representing their multiplication. Note i2 = -1 according to the definition.Example 1:Input: "1
2017-07-10 20:47:16 175
原创 parseint、valueof的用法
1.Integer.parseInt(String s)返回的是int类型;2.Integer.valueOf(String s)返回的是Integer类型;3.Integer类型的对象可以用object.intValue()转换成int类型;4.因为Integer是java为int提供的封装类,其实可以不用转换 Integer a = 3; int b = a;
2017-07-03 08:56:42 278
原创 lintcode/leetcode由易至难第21题:Encode and Decode TinyURL
Problem:Note: This is a companion problem to the System Design problem: Design TinyURL.TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/desig
2017-07-03 08:42:43 384
原创 lintcode/leetcode由易至难第20题:Integer Break
Problem:Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, gi
2017-06-26 22:53:10 195
原创 lintcode/leetcode由易至难第19题:Teemo Attacking
Problem:In LLP world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking ascending time series towards Ashe and the p
2017-06-26 22:02:02 151
原创 lintcode/leetcode由易至难第18题:Find Bottom Left Tree Value
Problem:Given a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1 3Output:1Example 2: Input: 1 / \
2017-06-26 18:55:01 164
原创 lintcode/leetcode由易至难第17题:Counting Bits
Problem:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:
2017-06-26 18:07:08 170
原创 String.valueOf()
在读取数据时需要对数据的强制转换,可采用String.valueOf(a),把a强制转换成字符串类型有时候a本来就已经是字符串类型了,但是为了代码的严谨性,也会加入String.valueOf(a),这时String.valueOf(a)省略也不会出错的但有时会涉及到服务器的问题,所以还是加入String.valueOf(a)比较好 使用 String.valueO
2017-06-21 21:45:50 308
原创 lintcode/leetcode由易至难第16题:Reshape the Matrix
Problem;:In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.You're given a matrix represent
2017-06-21 20:25:51 149
原创 lintcode/leetcode由易至难第15题:Merge Two Binary Trees
Problem:Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a
2017-06-21 19:52:14 173
原创 lintcode/leetcode由易至难第14题:Single Number
Problem:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it wit
2017-06-08 14:51:13 163
原创 lintcode/leetcode由易至难第13题:Max Consecutive Ones
Problem:Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits
2017-06-08 14:29:12 210
原创 lintcode/leetcode由易至难第12题:Majority Element
Problem:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the maj
2017-06-08 09:52:29 188
原创 lintcode/leetcode由易至难第11题:Same Tree
Problem:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
2017-06-08 09:38:27 213
原创 lintcode/leetcode由易至难第10题:Delete Node in a Linked List
Problem:Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third n
2017-06-08 09:16:18 195
原创 lintcode/leetcode由易至难第9题:Nim Game
Problem:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone
2017-06-07 22:24:52 199
原创 lintcode/leetcode由易至难第8题:Reverse String
Problem:Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".Code:public class Solution { public String reverseSt
2017-06-07 20:30:45 235
原创 lintcode/leetcode由易至难第7题:Distribute Candies
Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute the
2017-06-07 12:07:36 248
原创 lintcode/leetcode由易至难第6题:Number Complement
Problems:Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note:The given integer is guaranteed to fit wi
2017-06-06 22:50:44 216
原创 lintcode/leetcode由易至难第5题:Hamming Distance
Problem:The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.
2017-06-06 18:23:03 159
原创 lintcode/leetcode由易至难第4题:Array Partition I
题目:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as
2017-06-06 14:04:38 140
原创 lintcode/leetcode由易至难第3题:选择排序
public class Solution { /** * @param A an integer array * @return void */ //重点是记录指针!!!!派一个指针不断向后找 public void sortIntegers(int[] A) { // Write your code here
2017-05-08 14:18:09 329
原创 lintcode/leetcode由易至难第2题:冒泡排序
public class Solution { /** * @param A an integer array * @return void */ public void sortIntegers(int[] A) { // Write your code here if (A == null) return;
2017-05-08 11:04:59 1169
原创 lintcode/leetcode由易至难第1题:返回第n个斐波那契数
class Solution { /** * @param n: an integer * @return an integer f(n) */ public int fibonacci(int n) { // write your code here if(n == 1) return 0; if(n == 2) re
2017-04-23 17:01:16 396
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人