自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(7)
  • 收藏
  • 关注

原创 【leetcode】13. Roman to Integer

题目的描述如下: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 首先,罗马数字的表示方式如下: M:1000 D:500 C:100 L:50 X:10 V:5 I:1

2017-07-23 17:20:00 150

原创 【leetcode】142. Linked List Cycle II

第142是第141的一个升级版, Given a linked list, determine if it has a cycle in it. 141要求的是查出是否存在有一个链表的循环; Given a linked list, return the node where the cycle begins. If there is no cycle, return null.

2017-05-29 18:46:05 195

原创 【leetcode】Next Greater Element I

这个马住,以后再找更好的解决办法。这个就是强行解决问题。 public class Solution { public static int[] nextGreaterElement(int[] findNums, int[] nums) { int []compare = new int[findNums.length]; for(int i=0;i<find

2017-02-22 07:36:42 282

原创 【leetcode】Construct the Rectangle

主要是对Math.sqrt()方法的使用。 public class Solution { public int[] constructRectangle(int area) { int weight,length; length=(int) Math.sqrt(area); weight=(int) Math.sqrt(area); while(length*

2017-02-22 07:01:25 236

原创 【leetcode】Max Consecutive Ones

这个非常的简单,主要需要考虑的问题是: 如果最长连续1是在数组的尾部的话,那么最后flag值没有赋给sum的话会导致返回值错误。 public class Solution { public int findMaxConsecutiveOnes(int[] nums) { int sum=0; int flag=0; for(int i=0;i<nu

2017-02-22 06:42:22 234

原创 【leetcode】Reverse Integer

需要考虑的问题是一个int型数据在翻转后可能出现的越界问题。 而这个问题无法通过最开始对数据的约束来完成的。 比如说32bit的数据,最大值为2147483647,那么1463847412是可以翻转的数字,但是1253847412确实不可以反转的数字。 public class Solution { public int reverse(int x) {

2017-02-14 02:42:56 249

原创 【leetcode】Palindrome Number

这一题非常的容易,主要容易出错的位置是: 对base 的值进行更新的时候,需要减少两位数。因为之前删除了原数据一头一尾的内容。 另外,不要再代码中使用while(x>0 &&left==right)这样对于10这样的数字判断会出问题。 public class Solution { public boolean isPalindrome(int x) { int left=0;

2017-02-14 02:39:08 165

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除