上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页
摘要: 思路,这道题用二分,唯一的不同就是,1,a[left]= a[left]){ right = mid -1; } else{ left = mid + 1; ... 阅读全文
posted @ 2016-01-04 21:56 仔细思考一切 阅读(157) 评论(0) 推荐(0)
摘要: 这道题主义的就是,要利用数组自带的sort函数。此外,注意,利用hash来判断是否出现了。 public static ArrayList sortStrings(String[] str, int n) { // write code here Arra... 阅读全文
posted @ 2016-01-04 21:09 仔细思考一切 阅读(270) 评论(0) 推荐(0)
摘要: 1,牛客网的解题思路:其实这就是求一个最长的递增子序列。 以某一个箱子结尾的最大高度=放在它上面的所有类型中高度最大的那个+他自己的高度。import java.util.*; public class Box { public int getHeight(int[] w, int[] l,... 阅读全文
posted @ 2016-01-04 17:10 仔细思考一切 阅读(556) 评论(0) 推荐(0)
摘要: 思路:首先写一个检查能不能摆的函数。boolean checkValid(int[] columns,int row1, int column1);意思是row1行摆在column1列可不可以。然后是place函数。第一个参数row表示现在摆第几行。第一行可以摆n次位置,然后往下也是8ci。也就是相... 阅读全文
posted @ 2016-01-04 10:31 仔细思考一切 阅读(482) 评论(0) 推荐(0)
摘要: 这道题比较简单,就是通过从后往前复制大的就可以了。最后比较注意的就是如果B还没复制完要记得接着复制。import java.util.Arrays;public class Solution{ public static void main(String[] args){ int... 阅读全文
posted @ 2016-01-04 00:00 仔细思考一切 阅读(157) 评论(0) 推荐(0)
摘要: 这道题卡了一天。要想AC非常难。1,第一个解决办法,优化暴力:public class Coins { public static int countWays(int n){ int num25 = n / 25; long res = 0; for(int i = 0; i ... 阅读全文
posted @ 2016-01-03 23:00 仔细思考一切 阅读(280) 评论(0) 推荐(0)
摘要: ----思路:利用三个队列,一个存3,一个存5,一个存7.然后,3*3的都放第一个。然后3*5,5*5的放第二个。然后,3*7,5*7,7*7的都放第三个。答案: public static int findKth(int k){ ArrayList res = new Arra... 阅读全文
posted @ 2015-12-31 15:13 仔细思考一切 阅读(200) 评论(0) 推荐(0)
摘要: 用^来操作:public static int[] exchangeAB(int[] AB){ AB[0] = AB[0] ^ AB[1]; AB[1] = AB[0] ^ AB[1]; AB[0] = AB[0] ^ AB[1]; retur... 阅读全文
posted @ 2015-12-31 10:45 仔细思考一切 阅读(297) 评论(0) 推荐(0)
摘要: 直接两个点确定一条直线。然后两两组合,再写一个看过多少个点的函数。一直更新max就行。import java.util.Arrays;public class Solution { public static void main(String[] args){ Point[] a... 阅读全文
posted @ 2015-12-30 21:11 仔细思考一切 阅读(251) 评论(0) 推荐(0)
摘要: 最主要的思路:1,这条直线就是要把两个正方形的中点链接。2,注意的特殊情况:中心点重合。答案:public class Solution { public static void main(String[] args){ Point[] a = {new Point(13... 阅读全文
posted @ 2015-12-30 14:28 仔细思考一切 阅读(232) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 15 下一页