Fork me on GitHub
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 26 下一页
摘要: 递归解决方法 其他人解法也是大同小异 int climbStairs(int n){ int x1=0,x2=1; int i; int sum; for(i=1;i memo = new HashMap(); public int climbStairs(int n) { if(n 阅读全文
posted @ 2019-07-08 12:57 cznczai 阅读(102) 评论(0) 推荐(0) 编辑
摘要: public int findJudge(int N, int[][] trust) { if( N==1 && trust.length==0) { return 1; } if (trust.length != 0) { // arr用于投票记录 int arr[] = new int[1000 阅读全文
posted @ 2019-07-08 12:55 cznczai 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 题目介绍得有点问题 过程是将一组数组进行处理 处理后再返回有几个不同的项 class Solution { public int removeDuplicates(int[] nums) { if(nums.length==0) return 0; int i=0; for(int j=0; j 阅读全文
posted @ 2019-07-08 12:54 cznczai 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 思路导图 先用几个二维数组保存 abcd 用ASCII码保存在二维数组中 HashMap 一开始写不出来 卡了很久 class Solution { public List commonChars(String[] A) { List result = new ArrayList(); List l 阅读全文
posted @ 2019-07-08 12:52 cznczai 阅读(172) 评论(0) 推荐(0) 编辑
摘要: package leetcode; import java.util.Stack; public class Main { public boolean isValid(String S) { //一些前提条件 if (S == null || S.length() == 0) return tru 阅读全文
posted @ 2019-07-08 12:50 cznczai 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 动态规划解法 用两个for 阅读全文
posted @ 2019-07-08 12:44 cznczai 阅读(139) 评论(0) 推荐(0) 编辑
摘要: emmm 很遗憾超时间了 优化后 再次修改 分成两步 一步是判断是否已经是两个连接同样的字母在一起了 ,另一步则是添加 第二种不会超时 阅读全文
posted @ 2019-07-08 12:38 cznczai 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 感觉挺简单的 结果掉坑了 超时警告 public int countPrimes(int n) { int sum = 0; int[]arr = new int [n]; for(int i = 2 ;i 阅读全文
posted @ 2019-07-08 12:31 cznczai 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 这道题采用的是hashset 如果重复的话就return true 方法不难 public boolean containsDuplicate(int[] nums) { HashSet hs = new HashSet(); for(int i = 0 ;i 阅读全文
posted @ 2019-07-08 12:29 cznczai 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 这道题我的做法是进行排序 从小到大 取以一个数取反 再进行排序取反 每一次取的数都是最小的 如 10 变 10 排序 取第一个数 class Solution { public int largestSumAfterKNegations(int[] A, int K) { Arrays.sort(A 阅读全文
posted @ 2019-07-08 12:28 cznczai 阅读(128) 评论(0) 推荐(0) 编辑
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 26 下一页