- 博客(17)
- 收藏
- 关注
原创 MyCalendarI III Leetcode
[MyCalendar I 题目描述](https://leetcode.com/problems/my-calendar-i/)My Calendar I解题方法当两个事件[a,b)和[c,d)不发生冲突时必须满足b<=c or d<=a;所以当发生冲突时的情况是c<b and a<d,此时返回false;否则,添加并返回true; class MyCalen...
2019-02-25 20:35:49
206
原创 Number of Digit One(java实现)
Number of Digit One(java实现)[题目描述](https://leetcode.com/problems/number-of-digit-one/)解题思路1.[0,99]之间的数除了10-19之间有11个‘1’之外,其余区间都只有一个‘1’。若不考虑10-19区间多出来的10个‘1’,那么对任意一个两位数‘1’的个数等于十位数上的数字加1再加10即可,若十位上的...
2019-02-22 15:24:10
244
原创 Find Minimum in Rotated Sorted Array(java实现)
Find Minimum in Rotated Sorted Array(java实现)[题目描述](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/)class Solution { public int findMin(int [] nums){ int start =0,end = nums...
2019-01-05 21:23:33
224
原创 Search in Rotated Sorted Array LeetCode(java实现)
Search in Rotated Sorted Array LeetCode(java实现)[问题描述](https://leetcode.com/problems/search-in-rotated-sorted-array/)解题方法例如{0,1,2,3,4,5,6,7}这个有序数组旋转以后,会有如上图所示七种情况,我们可以观察出,当数组中间值小于最末尾值时,说明数组后半段递增有...
2019-01-02 21:03:39
182
原创 3Sum LeetCode(java实现)
3Sum LeetCode(java实现)[题目描述](https://leetcode.com/problems/3sum/)解题方法参照了leetcode上的解法,主要思想是将数组排序,然后用零减去第三个数,得到剩下两个数之和,再按照twosum的解法,求得剩下的两个数,在执行过程注意去重。class Solution { public List<List<Int...
2018-12-29 18:38:55
372
原创 Remove Nth Node From End of List Leetcode(java实现)
Remove Nth Node From End of List (java实现)[题目描述](https://leetcode.com/problems/remove-nth-node-from-end-of-list/)解题思路:初始化头结点,然后从前到后统计链表长度,当first指针为空时,将长度赋值为长度-n,再从前到后遍历一次,遍历到空时,说明这个节点为要移除的节点,然后将firs...
2018-12-26 15:33:08
154
原创 Container-with-the-most-water Leetcode(java实现)
Container-with-the-most-water Leetcode(java实现)[题目描述](https://leetcode.com/problems/container-with-most-water/)解题方法设置height数组首末两端同时向中间位置搜索,取左右最小值,并计算面积。当i<j,并且h等于i对应值时,左侧++;当i<j,并且h等于j对应值时,...
2018-12-20 15:49:27
127
原创 RomanToInt Leetcode(java实现)
RomanToInt Leetcode(java实现)题目描述(https://leetcode.com/problems/roman-to-integer/)解题方法此题与IntToRoman(https://blog.youkuaiyun.com/qq_35135923/article/details/85050170)情况类似,由于1-3 :I进行累加4 :IV,较小值的I在较大值V前...
2018-12-20 15:24:43
172
原创 Integer to Roman LeetCode(java实现)
Integer to Roman LeetCode(java实现)class Solution { public String intToRoman(int num) { char roman[] = {'M', 'D', 'C', 'L', 'X', 'V', 'I'}; int value[] = {1000, 500, 100, 50, 10, 5...
2018-12-17 15:27:40
201
原创 longest-common-prefix LeetCode(java实现)
class Solution { public String longestCommonPrefix(String[] strs) { int n = strs.length; if(n ==0) return ""; String prefix = strs[0]; for(int i=1;i&lt;n;i++){ ...
2018-12-15 16:49:26
119
原创 palindrome-number LeetCode(java实现)
palindrome-number LeetCode(java实现)题目描述点击此处了解第一种方法1.负数或者整除10的数直接返回false;2.将整型数转换为char类型数组,然后二分策略进行比较左右两侧字符是否相同,相同返回true,否则false;class Solution { public boolean isPalindrome(int x) { if...
2018-12-14 10:53:24
192
原创 Anaconda安装tensorflow并使用tensorboard可视化
Anaconda安装tensorflow并使用tensorboard可视化1.首先下载Anaconda(官网下载对应版本即可)输入如下命令,显示conda版本号,说明安装成功2.安装tensorflow打开Anaconda Prompt窗口输入conda create -n tensorflow python =3.6按回车(此处笔者的python版本是3.6)出现如下所示后,输入y...
2018-12-13 16:46:33
6957
1
原创 ZigZag-LeetCode题目解析(java实现)
ZigZag-LeetCode题目解析(java实现)题目描述黑色字符相差row,row等于2*numRows - 2,红色字符j +row -i(i指的是当前行数,j指的是前一字符的列数)package Leet_Code;public class ZigZag { public String convert(String s, int numRows) { S...
2018-12-11 17:34:20
390
原创 Reverse Integer-LeetCode(java实现)
Reverse Integer-LeetCode(java实现)题目描述此题目较为简单,记得考虑int类型最大值(正负)class Solution { public int reverse(int x) { int result =0; while(x!=0){ if(x==0|| Math.abs(result)>Integer.MAX_VALUE/...
2018-12-11 16:49:54
177
原创 Leetcode Add Two numbers 题目解析(java实现)
2. Leetcode Add Two numbers 题目解析(java实现)题目描述时间复杂度O(max(m,n)),首先根据链表长度区分三种情况,注释部分的ListNode类需提前声明。第一种方法:/** * Definition for singly-linked list. * public class ListNode { * int val; * Li...
2018-12-08 16:02:49
466
2
原创 Leetcode longest-substring-without-repeating-characters(java实现)
题目描述第一种解题方法题目是求最长无重复子字符串1.采用定义一个256位大小的整型数组来代替HashMap,保证了无重复性,256位长度是因ASCII表共能表示256个字符来记录所有字符。2.定义标记无重字符串最左边的位置和最终结果长度的int整型变量,left和res,遍历整个字符串:第一种情况:一直遍历没有遇到无重子串,则返回结果等于i - left +1,i为无重子串最右边的位置;...
2018-12-08 15:59:03
222
原创 Leetcode two sum 题目解析(java实现)
1. Leetcode two sum 题目解析题目描述第一种方法:暴力解析时间复杂度为O(n*n),两个for循环查找遍历。class Solution { public int[] twoSum(int[] nums, int target) { int res[] = new int[2]; for(int i = 0;i&amp;amp;lt;nums.le...
2018-12-04 11:22:16
787
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人