随笔分类 -  LeetCode

LeetCode:441. Arranging Coins
摘要:1 package day20170206; 2 //LeetCode:441. Arranging Coins 3 /* 4 You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. 5 Given n... 阅读全文

posted @ 2017-02-07 10:04 蒲公英的花朵 阅读(187) 评论(0) 推荐(0)

LeetCode:374. Guess Number Higher or Lower
摘要:1 package day20170206; 2 //LeetCode:374. Guess Number Higher or Lower 3 /* 4 We are playing the Guess Game. The game is as follows: 5 I pick a number from 1 to n. You have to guess which number... 阅读全文

posted @ 2017-02-07 10:03 蒲公英的花朵 阅读(220) 评论(0) 推荐(0)

LeetCode:53. Maximum Subarray
摘要:1 package day20170206; 2 //LeetCode:53. Maximum Subarray 3 /* 4 Find the contiguous subarray within an array (containing at least one number) which has the largest sum. 5 6 For example, given... 阅读全文

posted @ 2017-02-07 10:02 蒲公英的花朵 阅读(168) 评论(0) 推荐(0)

LeetCode:367. Valid Perfect Square
摘要:1 package day20170206; 2 //LeetCode:367. Valid Perfect Square 3 /* 4 Given a positive integer num, write a function which returns True if num is a perfect square else False. 5 6 Note: Do not ... 阅读全文

posted @ 2017-02-07 10:02 蒲公英的花朵 阅读(215) 评论(0) 推荐(0)

LeetCode:476. Number Complement
摘要:1 package Today; 2 //LeetCode:476. Number Complement 3 /* 4 Given a positive integer, output its complement number. 5 The complement strategy is to flip the bits of its binary representation.... 阅读全文

posted @ 2017-02-06 11:25 蒲公英的花朵 阅读(247) 评论(0) 推荐(0)

LeetCode:485. Max Consecutive Ones
摘要:1 package Today; 2 //LeetCode:485. Max Consecutive Ones 3 /* 4 Given a binary array, find the maximum number of consecutive 1s in this array. 5 6 Example 1: 7 Input: [1,1,0,1,1,1] 8 Output: ... 阅读全文

posted @ 2017-02-06 11:25 蒲公英的花朵 阅读(159) 评论(0) 推荐(0)

LeetCode:463. Island Perimeter
摘要:1 package Today; 2 //LeetCode:463. Island Perimeter 3 /* 4 You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. 5 Grid cells are conne... 阅读全文

posted @ 2017-02-06 11:24 蒲公英的花朵 阅读(271) 评论(0) 推荐(0)

LeetCode:167. Two Sum II - Input array is sorted
摘要:1 package Today; 2 3 import java.util.HashMap; 4 import java.util.Map; 5 6 //LeetCode:167. Two Sum II - Input array is sorted 7 /* 8 Given an array of integers that is already sorted in as... 阅读全文

posted @ 2017-02-06 11:23 蒲公英的花朵 阅读(191) 评论(0) 推荐(0)

LeetCode:492. Construct the Rectangle
摘要:1 package Today; 2 //LeetCode:492. Construct the Rectangle 3 /* 4 For a web developer, it is very important to know how to design a web page's size. 5 So, given a specific rectangular web pag... 阅读全文

posted @ 2017-02-06 11:23 蒲公英的花朵 阅读(408) 评论(0) 推荐(0)

LeetCode:453. Minimum Moves to Equal Array Elements
摘要:1 package Today; 2 //LeetCode:453. Minimum Moves to Equal Array Elements 3 /* 4 Given a non-empty integer array of size n, find the minimum number of moves required to make all array 5 elements... 阅读全文

posted @ 2017-02-06 11:22 蒲公英的花朵 阅读(125) 评论(0) 推荐(0)

LeetCode:35. Search Insert Position
摘要:1 package Today; 2 //LeetCode:35. Search Insert Position 3 /* 4 Given a sorted array and a target value, return the index if the target is found. 5 If not, return the index where it would be ... 阅读全文

posted @ 2017-02-06 11:21 蒲公英的花朵 阅读(133) 评论(0) 推荐(0)

LeetCode:459. Repeated Substring Pattern
摘要:package Today;//LeetCode:459. Repeated Substring Pattern/* Given a non-empty string check if it can be constructed by taking a substring of it and app 阅读全文

posted @ 2017-02-06 11:20 蒲公英的花朵 阅读(231) 评论(0) 推荐(0)

LeetCode:447. Number of Boomerangs
摘要:package HashTable;////Question 447. Number of Boomerangs/*Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of poin 阅读全文

posted @ 2017-02-03 17:07 蒲公英的花朵 阅读(257) 评论(0) 推荐(0)

LeetCode:268. Missing Number
摘要:package Math; import java.util.Arrays; //Question 268. Missing Number/* Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find 阅读全文

posted @ 2017-02-03 17:06 蒲公英的花朵 阅读(104) 评论(0) 推荐(0)

LeetCode:434. Number of Segments in a String
摘要:package String; import java.util.regex.Matcher;import java.util.regex.Pattern; //Question 434. Number of Segments in a String/*Count the number of seg 阅读全文

posted @ 2017-02-03 17:05 蒲公英的花朵 阅读(390) 评论(0) 推荐(0)

LeetCode:455. Assign Cookies
摘要:1 package Others; 2 3 import java.util.Arrays; 4 5 6 //Question 455. Assign Cookies 7 /* 8 Assume you are an awesome parent and want to give your children some cookies. 9 But, you should... 阅读全文

posted @ 2017-01-06 14:27 蒲公英的花朵 阅读(146) 评论(0) 推荐(0)

LeetCode:448. Find All Numbers Disappeared in an Array
摘要:1 package BitManipulation; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 //Question 448. Find All Numbers Disappeared in an Array 7 /* 8 Given an array of integers where 1 ≤ ... 阅读全文

posted @ 2017-01-06 12:34 蒲公英的花朵 阅读(270) 评论(0) 推荐(0)

LeetCode:461. Hamming Distance
摘要:1 package BitManipulation; 2 //Question 461. Hamming Distance 3 /* 4 The Hamming distance between two integers is the number of positions at which the corresponding bits are different. 5 Given t... 阅读全文

posted @ 2017-01-06 09:50 蒲公英的花朵 阅读(420) 评论(0) 推荐(0)

Java 正则表达式
摘要:java.util.regex包主要包括以下三个类: Pattern类: pattern对象是一个正则表达式的编译表示。Pattern类没有公共构造方法。要创建一个Pattern对象,你必须首先调用其公共静态编译方法,它返回一个Pattern对象。该方法接受一个正则表达式作为它的第一个参数。 Mat 阅读全文

posted @ 2016-10-09 13:47 蒲公英的花朵 阅读(150) 评论(0) 推荐(0)

Map.Entry
摘要:Map.Entry Map是java中的接口,Map.Entry是Map的一个内部接口。 Map提供了一些常用方法,如keySet()、entrySet()等方法,keySet()方法返回值是Map中key值的集合;entrySet()的返回值也是返回一个Set集合,此集合的类型为Map.Entry 阅读全文

posted @ 2016-10-09 09:06 蒲公英的花朵 阅读(161) 评论(0) 推荐(0)