![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LintCode
飘过的小熊
这个作者很懒,什么都没留下…
展开
-
LintCode----4.丑数II
原题目1.暴力 暴力就是从1开始循环然后判断是不是丑数。数据量大的时候直接超时,不过逻辑是正确的,过掉94%public class Main {//是不是丑数 public boolean isUgly(int n) { boolean result = false; if (n == 1) { return !result;原创 2017-08-28 13:59:56 · 220 阅读 · 0 评论 -
LintCode-----31.数组划分
原题目 使用快排的交换思想就行。值得注意的是,大于等于的数字一定要到左边。但是快排中等于是可以不动的。public class Solution { /* * @param nums: The integer array you should partition * @param k: An integer * @return: The index aft原创 2017-08-29 16:00:13 · 274 阅读 · 0 评论 -
LintCode-----17.带重复元素的子集
参考资料 加上去重复的条件就是了没注意一定要先sort一下public class Solution { /* * @param nums: A set of numbers. * @return: A list of lists. All valid subsets. */ public List<List<Integer>> subsetsWith原创 2017-08-29 15:00:54 · 329 阅读 · 0 评论 -
LintCode-----17.子集
原题目 我发现我已经写了两篇关于子集的博文,,,居然没写出来。1.通用型 以后可以用来求各种各样的子集。public class Solution { /* * @param nums: A set of numbers * @return: A list of lists */ public List<List<Integer>> subse原创 2017-08-29 00:25:55 · 1000 阅读 · 0 评论 -
LintCode-----16.带重复的全排列
原题目 再上一题的基础上做一点改动,就是判断是不是已经有了。不过时间3084ms,略慢class Solution { /** * @param nums: A list of integers. * @return: A list of unique permutations. */ public List<List<Integer>> perm原创 2017-08-28 23:44:51 · 299 阅读 · 0 评论 -
LintCode-----15.全排列
原题目1.自己 就是使用深搜.深搜很多用处,包括后面的什么子数组最大和等等。 1047msimport java.util.ArrayList;import java.util.List;public class Solution { public List<List<Integer>> permute(int[] nums) { // write your cod原创 2017-08-28 23:27:34 · 289 阅读 · 0 评论 -
LintCode-----12.带最小值操作的栈
1.自写 这里有坑就是关于栈为空的情况应怎么操作,我觉得这是比较省空间的/** * Created by XQF on 2017/8/13. */public class MinStack { Stack<Integer> s1; Stack<Integer> s2; int min = Integer.MAX_VALUE; public MinStack()原创 2017-08-28 22:55:19 · 311 阅读 · 0 评论 -
LintCode-----11.二叉查找树中搜索区间
原题目 中序遍历后比较 8056simport java.util.*;import java.lang.*;public class Solution { /* * @param root: param root: The root of the binary search tree * @param k1: An integer * @param k原创 2017-08-28 17:05:36 · 377 阅读 · 0 评论 -
LintCode-----7.二叉树的序列化和反序列化
原题目1.先序递归 772s import java.util.*; import java.lang.*;class Solution { String diviStr = "!"; String emptyNode = "#"; public String serialize(TreeNode root) { StringBuffer sb = new原创 2017-08-28 16:43:32 · 292 阅读 · 0 评论 -
LiintCode----3.统计数字
原题目 暴力也能过? 运行3500+sclass Solution { public int digitCounts(int k, int n) { int result = 0; String[] strs = new String[n + 1]; for (int i = 0; i <= n; i++) {原创 2017-08-28 14:15:24 · 296 阅读 · 0 评论 -
LintCode-----36.翻转链表 II
原题目1.使用中间容器是绝对不会错的 相对来说使用了额外的空间 2928 ms/** * Definition for ListNode * public class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next =原创 2017-09-01 01:54:18 · 267 阅读 · 0 评论