随笔分类 -  sf

摘要:class Solution { public int findRepeatNumber(int[] nums) { int temp; for(int i=0;i<nums.length;i++){ for (;nums[i]!=i;){ if(nums[i]==nums[nums[i]]){ r 阅读全文
posted @ 2020-08-29 21:37 soft.push("zzq") 阅读(99) 评论(0) 推荐(0)
摘要:public int reversePairs(int[] nums) { int cnt = 0; int len = nums.length; for (int i = 0; i < len - 1; i++) { for (int j = i + 1; j < len; j++) { if ( 阅读全文
posted @ 2020-08-29 21:33 soft.push("zzq") 阅读(165) 评论(0) 推荐(0)
摘要:/** * 循环有序的数组进行二分查找 * @param A */ public static int find(int[] A, int n, int target){ if(n<=0) return -1; int left = 0, right = n-1; while(left<=right 阅读全文
posted @ 2020-08-29 20:38 soft.push("zzq") 阅读(346) 评论(0) 推荐(0)
摘要:public static int strToInt(String str) { char[] s = str.trim().toCharArray(); int len = s.length; // 去除空格后长度为0则返回0 if (len == 0) return 0; int sign = 阅读全文
posted @ 2020-08-29 13:33 soft.push("zzq") 阅读(159) 评论(0) 推荐(0)
摘要:1.题目描述 给定a、b两个文件,各存放50亿个url,每个url各占64字节,内存限制是4G,让你找出a、b文件共同的url? 2.思考过程 (1)首先我们最常想到的方法是读取文件a,建立哈希表(为什么要建立hash表?因为方便后面的查找),然后再读取文件b,遍历文件b中每个url,对于每个遍历, 阅读全文
posted @ 2020-08-28 16:15 soft.push("zzq") 阅读(227) 评论(0) 推荐(0)
摘要:public static int MaxDiff(int[] arr) { if(arr==null || arr.length<2) return -1; //error int min=arr[0]; //最大利润可以是负数,只要亏损最小就行 int maxDiff=arr[1]-min; f 阅读全文
posted @ 2020-08-28 14:04 soft.push("zzq") 阅读(121) 评论(0) 推荐(0)
摘要:static Node reverseLinkedList(Node node) { Node previousNode = null; Node currentNode = node; Node headNode = null; while (currentNode != null) { Node 阅读全文
posted @ 2020-08-27 16:43 soft.push("zzq") 阅读(137) 评论(0) 推荐(0)
摘要:/** * 多线程处理list * * @param data 数据list * @param threadNum 线程数 */ public static int handleList(List<Integer> data, int threadNum) { int length = data.s 阅读全文
posted @ 2020-08-26 15:27 soft.push("zzq") 阅读(228) 评论(0) 推荐(0)
摘要:public static void strZip(String s) { for (int i = 0; i < s.length(); i++) { int sum = 0; for (; (i + 1 < s.length()) && (s.charAt(i) == s.charAt(i + 阅读全文
posted @ 2020-08-26 11:01 soft.push("zzq") 阅读(122) 评论(0) 推荐(0)
摘要:public static ListNode reveseList (ListNode head) { // write code here ListNode tmp=head.next; ListNode newHead=reveseList(head.next); tmp.next=head; 阅读全文
posted @ 2020-08-21 14:18 soft.push("zzq") 阅读(79) 评论(0) 推荐(0)
摘要:public static void main(String[] args) { Random rand = new Random(); int[] arr1 = new int[10]; int[] arr2 = new int[15]; for(int i = 0; i < 10; i++) { 阅读全文
posted @ 2020-08-21 11:54 soft.push("zzq") 阅读(448) 评论(0) 推荐(0)
摘要:public class Test { volatile int i = 1; public static void main(String[] args) throws Exception { Test obj = new Test(); Runnable runnable = new Runna 阅读全文
posted @ 2020-08-19 08:06 soft.push("zzq") 阅读(1753) 评论(0) 推荐(0)
摘要:public static String longestPalindrome1(String s) { int startAndEnd[] = new int[2]; for (int i = 0; i < s.length(); i++) { getMaxSubStr(s, startAndEnd 阅读全文
posted @ 2020-08-08 12:12 soft.push("zzq") 阅读(78) 评论(0) 推荐(0)
摘要:public static void main(String[] args) { List<List<Integer>> list = m1(new int[]{1, 2, 3}); System.out.println(""); } public static List<List<Integer> 阅读全文
posted @ 2020-08-08 11:18 soft.push("zzq") 阅读(238) 评论(0) 推荐(0)
摘要:public class Node { //定义Node节点 static class ListNode { public int val; public ListNode next = null; public ListNode(int val) { this.val = val; } } pub 阅读全文
posted @ 2020-08-08 11:06 soft.push("zzq") 阅读(151) 评论(0) 推荐(0)
摘要:动态规划,典型最大礼物数 public static void main1() { int num[][] = new int[][]{ {1, 3, 6, 8, 9}, {1, 6, 1, 3, 0}, {2, 6, 5, 4, 1}, }; int rows = num.length; int 阅读全文
posted @ 2020-05-26 16:50 soft.push("zzq") 阅读(147) 评论(0) 推荐(0)