自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

刘子阳的博客

新车上路

  • 博客(16)
  • 收藏
  • 关注

原创 437. Path Sum III#1

Solution#1 Problem#1*没有思路

2017-01-10 15:05:50 152

原创 326. Power of Three#1

Solution#1Problem#1 数学的方法

2017-01-09 22:13:04 157

原创 459. Repeated Substring Pattern#2

Solution#1 Problem#1 思路不清楚

2017-01-09 20:11:41 152

原创 405. Convert a Number to Hexadecimal#2

Solution#1 Problem#1 试着用位操作去解决,而不是通过触发

2017-01-08 22:02:28 152

原创 415. Add Strings#1(Done)

Solution#1public class Solution { public String addStrings(String num1, String num2) { if (num1.equals("0")) return num2; if (num2.equals("0")) return num1;

2017-01-08 21:22:54 162

原创 401. Binary Watch#1(Done)

Solution#1public class Solution { public List<String> readBinaryWatch(int num) { if (num < 0 || num > 10) throw new IllegalArgumentException("the argument for readBinaryWatch is

2017-01-08 16:28:58 269

原创 387. First Unique Character in a String

题目摘要 给定一个字符串,返回第一个没有重复的字母的下标,如果不存在,返回-1。假设字符串中只含有小写字母。

2017-01-08 14:22:38 141

原创 447. Number of Boomerangs

题目摘要 给定平面上的n个点,一个”boomerangs”值三个点(i, j, k),i到j的距离和i到k的距离相等,找到boomerangs的数量。解法 遍历二元数组n,每次循环,将改点与其它点的<距离, 该距离点数量>存到一个hashmap里,每次循环boomerangs的数量为map的每个value * (value - 1)相加public class Solution { pu

2017-01-06 21:12:35 148

原创 387. First Unique Character in a String#2(Done)

Solution#1public class Solution { public int firstUniqChar(String s) { if (s == null || s.length() == 0) return -1; int[] position = new int[26]; for (int i = 0

2017-01-03 22:08:28 181

原创 447. Number of Boomerangs#2(Done)

Solution#1Problem#1 map的用法,getOrDefault(key, default),遍历方法

2017-01-03 20:21:58 142

原创 404. Sum of Left Leaves#2(Done)

Solution#2/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ // 递归 public cl

2017-01-03 16:27:24 132

原创 383. Ransom Note#1(Done)

Solution#1public class Solution { public boolean canConstruct(String ransomNote, String magazine) { int[] table = new int[26]; // char[] mc = magezine.toCharArray(); for (ch

2017-01-03 11:59:28 308

原创 448. Find All Numbers Disappeared in an Array

题目摘要 给定一个整形数组,其中1≤a[i]≤n(n为数组长度),一些元素出现两次一些元素只出现一次,找到1~n中所有没有出现的元素。请用O(n)的时间复杂度,并且不使用额外的空间。

2017-01-03 11:23:42 197

原创 453. Minimum Moves to Equal Array Elements

题目摘要 给定一个非空n长数组,找出使数组所有元素相等的最小步数,每一步操作为将数组中n-1个元素加一。解法 设tmp = nums[0],遍历数组,如果nums[i] > tmp,则步数result += nums[i] - tmp,如果nums[i] < tmp,则步数result += (tmp - nums[i]) * i; tmp = nums[i];public class Solu

2017-01-01 18:31:48 198

原创 453. Minimum Moves to Equal Array Elements#1(Done)

Solution#1public class Solution { public int minMoves(int[] nums) { int result = 0; int tmp = nums[0]; for (int i = 0; i < nums.length; i++) { if (tmp < nums[i])

2017-01-01 18:24:53 146

原创 448. Find All Numbers Disappeared in an Array#2(Done)

Solution#1public class Solution { public List<Integer> findDisappearedNumbers(int[] nums) { List<Integer> list = new ArrayList<>(); if (nums == null || nums.length == 0) return list

2017-01-01 17:44:20 136

空空如也

空空如也

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

TA关注的人

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