
java
文章平均质量分 78
zsy112371
这个作者很懒,什么都没留下…
展开
-
@PathVariable问题1
使用@PathVariable时可能会遇到的问题原创 2022-06-09 11:05:19 · 197 阅读 · 0 评论 -
最大重叠区间个数--java实现
主要思路来源于下面这个博客:https://blog.youkuaiyun.com/qq_42060170/article/details/104241823在细节上,做了一些修改:(1)定义了新的Comparator接口,使之能正确针对左闭右开区间进行排序(2)原文中的Point类对应于本文的Interval类,删除类原文中的Interval类(3)增加了控制台的输入和输出(4)原文...原创 2020-04-27 15:21:47 · 2746 阅读 · 1 评论 -
java实现一个bitmap--《编程珠玑ch1》
/** * 用于排序一个满足以下条件的文件: * (1) 文件中只范围在0~1024*1024*8-1的整数 * (2) 每个数字只出现1次或0次 * 使用到的数组大小: * 约1MB * 排序时间复杂度: * O(n), n为文件中出现的数字总数 */public class BitMap { public static vo...原创 2020-04-26 15:24:11 · 256 阅读 · 1 评论 -
关于LeetCode中Rectangle Area一题的理解
题目如下:Find the total area covered by two rectilinear rectangles in a2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume that th原创 2016-09-05 21:13:52 · 575 阅读 · 0 评论 -
关于LeetCode中Merge Sorted Array一题的理解
题目如下;Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to原创 2016-09-17 22:02:44 · 1420 阅读 · 0 评论 -
关于LeetCode中Longest Common Prefix一题的理解
题目如下:Write a function to find the longest common prefix string amongst an array of strings. 给定一个String类型数组,要求写一个方法,返回数组中这些字符串的最长公共前缀。举个例子:假如数组为["123","12","4"],经过这个方法返回的结果就应该是""。因为"123","12",原创 2016-09-04 18:33:06 · 8656 阅读 · 3 评论 -
关于LeetCode中Remove Linked List Elements一题的理解
题目如下:Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5原创 2016-09-04 17:23:48 · 450 阅读 · 0 评论 -
关于LeetCode中Roman to Integer一题的理解
题目如下:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999. 题目的意思很明确,我们只要知道罗马数字的计算规则就可以写出这道题的答案了,直接看百度百科关于罗马数字的解释就可以,链接在这里:http://bai原创 2016-09-16 17:56:11 · 336 阅读 · 0 评论 -
<中秋节番外>编程之美之课后练习(一)
今天是中秋假期的第二天,上午打了一上午的炉石,买了30元十包的新手包,毫不意外地啥也没开出来......好了,言归正传。今天的习题是这样的:给定两个正整数(二进制形式表示)A和B,问把A变为B需要改变多少位(bit)?也就是说,整数A和B的二进制表示中有多少位是不同的? 解决这个问题的思路应该分两步走:(1)找到A和B中所有不同的位;(2)将找到的不同的位进行计数。 第原创 2016-09-16 14:48:10 · 475 阅读 · 0 评论 -
关于LeetCode中Palindrome Linked List一题的理解
题目如下:Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space? 题目还是很简单,判断一个链表是不是“回文链表”。然后稍微难一点的是是否能够用O(n)的时间复杂度和O(1)空间复杂度完成这个方原创 2016-09-03 23:09:13 · 381 阅读 · 0 评论 -
关于LeetCode中House Robber一题的理解
题目如下:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adj原创 2016-09-14 23:03:43 · 870 阅读 · 0 评论 -
关于LeetCode中Symmetric Tree一题的理解
题目如下:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \原创 2016-09-03 16:54:06 · 1269 阅读 · 0 评论 -
关于LeetCode中Valid Anagram一题的理解
题目如下:Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:Yo原创 2016-08-24 14:01:35 · 610 阅读 · 0 评论 -
关于LeetCode中Reverse Vowels of a String一题的理解
题目如下:Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Given s = "hello", return "holle".Example 2:Given s = "leetcode", return "leotced原创 2016-09-02 22:54:27 · 329 阅读 · 0 评论 -
关于LeetCode中Remove Element一题的理解
题目如下:Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant原创 2016-09-02 21:05:59 · 1433 阅读 · 2 评论 -
关于LeetCode中Maximum Depth of Binary Tree一题的理解
题目如下:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 题目内容也非常简单,给定一个二叉树的根结点原创 2016-08-23 21:58:37 · 309 阅读 · 0 评论 -
关于LeetCode中Palindrome Number一题的理解
题目如下:Determine whether an integer is a palindrome. Do this without extra space. 判断一个数是否为“回文数”,禁止使用额外的存储空间。 按例奉上自己的Low B思路及已Accepted的代码。我第一眼看到这个题目的时候想法很简单,先查看给定数的最高位和最低位的数值是否相等,然后查看次高位和次低原创 2016-08-25 22:46:12 · 366 阅读 · 0 评论 -
关于LeetCode中Swap Nodes in Pairs一题的理解
题目如下:Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant spa原创 2016-09-05 19:46:28 · 627 阅读 · 0 评论 -
关于LeetCode中Valid Parentheses一题的理解
题目如下:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are原创 2016-09-22 16:19:55 · 3607 阅读 · 0 评论 -
关于LeetCode中Binary Watch一题的理解
题目如下:A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LED represents a zero or one, with the least significan原创 2016-09-25 19:36:38 · 979 阅读 · 0 评论 -
关于LeetCode中Word Pattern一题的理解
题目如下:Given a pattern and a stringstr, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter inpattern and a non-empty word in s原创 2016-09-08 20:43:04 · 364 阅读 · 0 评论 -
关于LeetCode中Guess Number Higher or Lower一题的理解
题目如下:We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I'll tell you whether the number i原创 2016-09-08 13:52:13 · 2318 阅读 · 0 评论 -
关于LeetCode中Remove Duplicates from Sorted List一题的理解
题目如下:Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3. 这道题还是很有意思的原创 2016-09-02 17:47:38 · 373 阅读 · 0 评论 -
关于LeetCode中Isomorphic Strings一题的理解
题目如下:Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to gett.All occurrences of a character must be replaced wit原创 2016-09-07 18:31:53 · 1538 阅读 · 0 评论 -
关于LeetCode中Linked List Cycle一题的理解
题目如下:Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space? 题目的要求是判断一个链表中是否存在环。这个题目我还是想了很久的,最开始的思路是判断随着指针节点移动,其必然会与开始节点即head节点重合,如果重原创 2016-09-07 16:27:12 · 527 阅读 · 0 评论 -
关于LeetCode中Factorial Trailing Zeroes一题的理解
题目如下:Given an integer n, return the number of trailing zeroes inn!.Note: Your solution should be in logarithmic time complexity 给定一个int类型的整数,求它的阶乘尾部有几个0。举例来说,如果输入是5,那么5!等于120,120尾部有一个0,所以原创 2016-09-07 13:18:53 · 300 阅读 · 0 评论 -
关于LeetCode中Nth Digit一题的理解
题目如下:Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...Note:n is positive and will fit within the range of a 32-bit signed integer (n 31).Exampl原创 2016-09-19 21:52:33 · 812 阅读 · 0 评论 -
关于LeetCode中Lowest Common Ancestor of a Binary Search Tree一题的理解
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.原创 2016-09-06 19:35:20 · 233 阅读 · 0 评论 -
关于LeetCode中ZigZag Conversion一题的理解
题目如下:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P原创 2016-09-18 18:40:24 · 846 阅读 · 0 评论 -
关于LeetCode中Invert Binary Tree一题的理解
题目如下:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by this original tweet by原创 2016-08-26 11:56:29 · 428 阅读 · 0 评论 -
关于LeetCode中Bulls and Cows的理解
题目如下:You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provi原创 2016-09-13 18:03:43 · 787 阅读 · 0 评论 -
关于LeetCode中First Unique Character in a String一题的理解
题目如下:Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.原创 2016-09-01 14:10:27 · 480 阅读 · 0 评论 -
关于LeetCode中Intersection of Two Arrays II一题的理解
题目如下:Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note:Each element in the result should a原创 2016-08-29 17:24:09 · 564 阅读 · 0 评论 -
关于LeetCode中Ransom Note一题的理解
题目如下: Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can原创 2016-08-29 17:20:40 · 7045 阅读 · 1 评论 -
关于LeetCode中Best Time to Buy and Sell Stock一题的理解
题目如下:Say you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the原创 2016-09-09 13:55:36 · 3088 阅读 · 1 评论 -
关于LeetCode中Reverse Integer一题的理解
题目如下:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321原创 2016-08-27 16:46:09 · 843 阅读 · 0 评论 -
关于LeetCode中Intersection of Two Arrays一题的理解
题目如下:Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be uni原创 2016-08-27 12:22:16 · 1280 阅读 · 0 评论 -
Java生产者-消费者模式的非阻塞队列实现
package hit.zsy.cn;import java.util.PriorityQueue;public class TestConPro { private int queueSize = 10; private PriorityQueue queue = new PriorityQueue(queueSize); public static void main(Str转载 2015-04-12 10:39:57 · 694 阅读 · 0 评论 -
Java生产者-消费者模式的阻塞队列实现
package hit.zsy.cn;import java.util.concurrent.ArrayBlockingQueue;public class TestProCon2 { private int queueSize = 10; private ArrayBlockingQueue queue = new ArrayBlockingQueue(queueSize); p转载 2015-04-12 11:03:25 · 337 阅读 · 0 评论 -
java ThreadLocal深入解析
作者:海子 出处:http://www.cnblogs.com/dolphin0520/ 本博客中未标明转载的文章归作者海子和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。Java学习笔记(2)ThreadLocal什么是ThreadLocal:线程本地变量,T转载 2015-03-23 23:15:23 · 366 阅读 · 0 评论