- 博客(6)
- 收藏
- 关注
原创 [LeetCode]401. Binary Watch
题目大意:点击打开链接 思路:把手表上的每个LED灯看做一个二进制位,如果灯是亮的就代表1,不用在意LED灯的位置,转化为计算一共有多少个给定数字的组合(参考题目给的Example 1,num=1),并在一个List里打印出来这些组合。 public class Solution { public List readBinaryWatch(int num) {
2016-12-29 10:13:13 634
原创 [LeetCode]179. Largest Number
Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330. Note: The result may be ve
2016-12-24 11:55:25 288
原创 [LeetCode]78. Subsets
Given a set of distinct integers, nums, return all possible subsets. 具体题目要求:点击打开链接 思路:例如数组[1,2,3] 先添加空new ArrayList; ([ ]) 对于数组nums[0]=1,添加到刚才的空ArrayList里面,然后把当前结果添加到暂时的汇总ArrayList temp里面;
2016-12-24 08:29:44 289
原创 [LeetCode]413. Arithmetic Slices
A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. 具体题目要求:点击打开链接 思路: 查看三个条件:1.数组A长
2016-12-23 11:25:48 285
原创 [LeetCode]451. Sort Characters By Frequency
Given a string, sort it in decreasing order based on the frequency of characters. 点击打开链接 这是一道运用HashMap的相关基础用法的题。 思路: 1:统计每个字母和出现相应次数; 2:把字母和出现次数的相应关系储存到list里; 3:按出现次数把第二步list里的相应关系按升序排列;
2016-12-23 01:49:53 934
原创 [LeetCode]108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 是一道比较简单的递归题。 像二分查找一样,不断地把升序数组切半,分别看做新的数组,再切半。。。 这边要注意:如果low > high, 返回空结点。
2016-12-14 04:42:09 215
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人