E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
leetcode-java
leetcode-java
二进制求和
二进制求和题目描述:给定两个二进制字符串,返回他们的和(用二进制表示)。输入为非空字符串且只包含数字1和0。示例1:输入:a="11",b="1"输出:"100"示例2:输入:a="1010",b="1011"输出:"10101"问题分析:关于这个题,有两种大的解题思路:1,作为使用java解答的算法题,可以直接使用字符函数进行操作,借助StringBuilderres=newStringBuil
宝宝辉AD
·
2020-07-11 20:00
leetcode
java
Leetcode-Java
(四)
31.NextPermutation分三步:https://leetcode.com/problems/next-permutation/solution/1、首先找到相邻的两个元素,前面一个元素值小于后面一个元素值,即nums[i]=0&&nums[i+1]=0){intj=nums.length-1;while(j>=0&&nums[j]=2?dp[i-2]:0)+2;}elseif(i-dp
文哥的学习日记
·
2020-07-06 00:15
Implement strStr()-
leetcode-java
28.ImplementstrStr()-
leetcode-java
发表于2016/02/06题意ImplementstrStr().Returnstheindexofthefirstoccurrenceofneedleinhaystack
靠靠的博客
·
2020-07-02 01:24
LeetCode
leetcode-java
有效的数独
有效的数独题目描述:leetcode36.有效的数独*判断一个9x9的数独是否有效。只需要根据以下规则,验证已经填入的数字是否有效即可。数字1-9在每一行只能出现一次。数字1-9在每一列只能出现一次。数字1-9在每一个以粗实线分隔的3x3宫内只能出现一次。上图是一个部分填充的有效的数独。数独部分空格内已填入了数字,空白格用'.'表示。示例1:输入:[["5","3",".",".","7","."
宝宝辉AD
·
2020-06-25 22:10
java
leetcode
Leetcode-Java
(十九)
181.EmployeesEarningMoreThanTheirManagers#WriteyourMySQLquerystatementbelowselectt1.NameasEmployeefrom(select*fromEmployee)t1innerjoin(select*fromEmployee)t2ont1.ManagerId=t2.Idwheret1.Salary>t2.Salar
文哥的学习日记
·
2020-06-25 10:52
Leetcode-Java
(二十七)
263.UglyNumberclassSolution{publicbooleanisUgly(intnum){if(num==1)returntrue;if(num==0)returnfalse;while(num%2==0)num=num>>1;while(num%3==0)num=num/3;while(num%5==0)num=num/5;returnnum==1;}}264.UglyNu
文哥的学习日记
·
2020-06-23 08:06
Leetcode-Java
(十八)
171.ExcelSheetColumnNumberclassSolution{publicinttitleToNumber(Strings){if(s==null||s.length()==0)return0;intres=0;for(inti=0;istack;publicBSTIterator(TreeNoderoot){stack=newStack();if(root!=null){Tre
文哥的学习日记
·
2020-06-23 05:36
【
LeetCode-Java
实现】15. 3Sum
15.3Sum题目描述思路实现题目描述Givenanarraynumsofnintegers,arethereelementsa,b,cinnumssuchthata+b+c=0?Findalluniquetripletsinthearraywhichgivesthesumofzero.Note:Thesolutionsetmustnotcontainduplicatetriplets.给一个整数
IT Crowd
·
2020-06-22 21:42
LeetCode
LeetCode
Java
算法
leetcode-java
反转字符串
反转字符串反转字符串I题目描述:leetcode344.反转字符串编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组char[]的形式给出。不要给另外的数组分配额外的空间,你必须原地修改输入数组、使用O(1)的额外空间解决这一问题。你可以假设数组中的所有字符都是ASCII码表中的可打印字符。示例1:输入:["h","e","l","l","o"]输出:["o","l","l","e
宝宝辉AD
·
2020-06-21 06:51
leetcode
java
LeetCode-Java
解题常用类方法-持续更新中
开刷LeetCode,把一些Java中常用类的方法,归纳整理,方便今后查阅。不断更新中。。。。。。字符串String转int、long等publicvoidtest(){StringsInt="123";ints=Integer.parseInt(sInt);longls=Long.parseLong(sInt);System.out.println(s+""+ls);}StringBufferS
tikyle
·
2020-03-27 15:15
Leetcode-Java
(十三)
121.BestTimetoBuyandSellStock如果把数组中的两个数两两作差,那么这道题跟求数组中的和最大的子序列是相同的,我们可以参照前面的题的做法。classSolution{publicintmaxProfit(int[]prices){if(prices==null||prices.length=0;i--){desc[i]=Math.max(maxprice-prices[i]
文哥的学习日记
·
2019-12-11 19:28
leetcode-java
删除排序链表中的重复元素II
删除排序链表中的重复元素II删除排序链表中的重复元素I题目描述:给定一个排序链表,删除所有含有重复数字的节点,只保留原始链表中没有重复出现的数字。示例1:输入:1->2->3->3->4->4->5输出:1->2->5示例2:输入:1->1->1->2->3输出:2->3问题分析:比着之前的删除排序链表的重复元素I,来说,它不需要保留重复的所有元素,一旦发现重复,所有元素都要删除第一种方法:双指针
宝宝辉AD
·
2019-11-15 14:07
数据结构与算法
java
leetcode
leetcode
java
删除排序链表中的重复元素II
[
Leetcode-java
] 1160. Find Words That Can Be Formed by Characters
一、问题链接:https://leetcode.com/problems/find-words-that-can-be-formed-by-characters/Example1:Input:words=["cat","bt","hat","tree"],chars="atach"Output:6Explanation:Thestringsthatcanbeformedare"cat"and"ha
喵喵喵1221
·
2019-08-20 23:07
[
Leetcode-java
] 1160. Find Words That Can Be Formed by Characters
一、问题链接:https://leetcode.com/problems/find-words-that-can-be-formed-by-characters/Example1:Input:words=["cat","bt","hat","tree"],chars="atach"Output:6Explanation:Thestringsthatcanbeformedare"cat"and"ha
喵喵喵1221
·
2019-08-20 23:07
[
Leetcode-java
] 56. Merge Intervals:计算重叠数组
一、问题链接:https://leetcode.com/problems/merge-intervals/问题是针对提出的二维数组,去掉交叉的部分,计算出部分重叠的数组变更点:之前传入的参数为list对象,此次改成了二维数组二、思路:1、先对二维数组中的一维数组左端(类似于线段的起点开始排序)2、根据排序后的数组的值,按顺序遍历遍历数组元素,结合最后合并成功的元素来融合3、合并的情况如下所示:be
喵喵喵1221
·
2019-08-15 23:47
[
Leetcode-java
] 56. Merge Intervals:计算重叠数组
一、问题链接:https://leetcode.com/problems/merge-intervals/问题是针对提出的二维数组,去掉交叉的部分,计算出部分重叠的数组变更点:之前传入的参数为list对象,此次改成了二维数组二、思路:1、先对二维数组中的一维数组左端(类似于线段的起点开始排序)2、根据排序后的数组的值,按顺序遍历遍历数组元素,结合最后合并成功的元素来融合3、合并的情况如下所示:be
喵喵喵1221
·
2019-08-15 23:47
leetcode-java
删除排序链表中的重复元素
删除排序链表中的重复元素题目描述:给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次。示例1:输入:1->1->2输出:1->2示例2:输入:1->1->2->3->3输出:1->2->3问题分析:问题比较简单,判断和下一个结点的值是否相等,相等则跳过直接到下一个元素,直到遇到不等。第一种方法:直接在对head结点操作if(head.val==head.next.val)head.nex
宝宝辉AD
·
2019-06-22 11:15
leetcode
java
删除链表中的重复元素
leetcode
java
链表的操作
链表删除元素
【
LeetCode-Java
实现】53. Maximum Subarray
53.MaximumSubarray题目描述解题思路实现代码题目描述Givenanintegerarraynums,findthecontiguoussubarray(containingatleastonenumber)whichhasthelargestsumandreturnitssum.Example:Input:[-2,1,-3,4,-1,2,1,-5,4],Output:6Explan
IT Crowd
·
2019-04-27 22:42
LeetCode
动态规划
Leetcode-Java
(十一)
101.SymmetricTree递归求解/***Definitionforabinarytreenode.*publicclassTreeNode{*intval;*TreeNodeleft;*TreeNoderight;*TreeNode(intx){val=x;}*}*/classSolution{publicbooleanisSymmetric(TreeNoderoot){if(root=
文哥的学习日记
·
2018-03-18 10:43
Leetcode-Java
(八)
72.EditDistance动态规划:publicclassSolution{publicintminDistance(Stringword1,Stringword2){intm=word1.length();intn=word2.length();int[][]cost=newint[m+1][n+1];for(inti=0;imap=newHashMap();for(inti=0;i0){f
文哥的学习日记
·
2018-03-15 11:16
[
LeetCode-Java
]3. Longest Substring Without Repeating Characters
Givenastring,findthelengthofthelongestsubstringwithoutrepeatingcharacters.Examples:Given“abcabcbb”,theansweris“abc”,whichthelengthis3.Given“bbbbb”,theansweris“b”,withthelengthof1.Given“pwwkew”,theansw
如故1994
·
2016-09-24 17:56
LeetCode
Implement strStr()-
leetcode-java
28.ImplementstrStr()-
leetcode-java
发表于 2016/02/06题意ImplementstrStr().Returnstheindexofthefirstoccurrenceofneedleinhaystack
hahawhyha
·
2016-05-06 18:00
Pow(x, n)-
leetcode-java
50.Pow(x,n)-
leetcode-java
发表于 2016/02/06题目Implementpow(x, n). 实现浮点类型的幂运算,x的n次幂。
hahawhyha
·
2016-05-06 18:00
[
LeetCode-JAVA
] Course Schedule
题目: There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have to first take course
·
2015-10-28 08:54
LeetCode
[
LeetCode-JAVA
] Binary Tree Inorder Traversal
题目: Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2].
·
2015-10-28 08:54
LeetCode
[
LeetCode-JAVA
] Majority Element II
题目:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space. 题意:找到数组中权重大于⌊ n/3 ⌋的数字(成为众数)。 思路
·
2015-06-29 20:00
LeetCode
[
LeetCode-JAVA
] Basic Calculator II
题目: Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators and empty
·
2015-06-29 19:00
LeetCode
[
LeetCode-JAVA
] The Skyline Problem
题目:题目太长了,见链接-- > The Skyline Problem Notes: The number of buildings in any input list is guaranteed to be in the range [0, 10000]. The input list is already sorted in ascendi
·
2015-06-21 16:00
LeetCode
[
LeetCode-JAVA
] Invert Binary Tree
题目: Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia:This problem was inspired by this original tweet
·
2015-06-20 12:00
LeetCode
[
LeetCode-JAVA
] Implement Stack using Queues
题目: Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. empty()
·
2015-06-20 11:00
LeetCode
[
LeetCode-JAVA
] Basic Calculator
题目: Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or minus sign -,
·
2015-06-20 11:00
LeetCode
[
LeetCode-JAVA
] Count Complete Tree Nodes
题目: Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is co
·
2015-06-19 11:00
LeetCode
[
LeetCode-JAVA
] Shortest Palindrome
题目: Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation. For e
·
2015-06-18 21:00
LeetCode
[
LeetCode-JAVA
] Best Time to Buy and Sell Stock IV
题目: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most k transa
·
2015-06-18 09:00
LeetCode
[
LeetCode-JAVA
] Word Ladder II
题目: Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: Only one letter can be changed at a time
·
2015-06-14 14:00
LeetCode
[
LeetCode-JAVA
] Jump Game II
题目: Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal
·
2015-06-08 20:00
LeetCode
[
LeetCode-JAVA
] Substring with Concatenation of All Words
题目: You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in&
·
2015-06-05 20:00
substring
[
LeetCode-JAVA
] Reverse Nodes in k-Group
题目: Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end
·
2015-06-05 15:00
LeetCode
[
LeetCode-JAVA
] Median of Two Sorted Arrays
题目: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 思路
·
2015-06-04 20:00
LeetCode
[
LeetCode-JAVA
] Contains Duplicate IIIMaximal Square
题目: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area. For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0
·
2015-06-04 16:00
LeetCode
[
LeetCode-JAVA
] Contains Duplicate III
题目:Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at m
·
2015-06-04 14:00
LeetCode
[
LeetCode-JAVA
] Add and Search Word - Data structure design
题目: Design a data structure that supports the following two operations: void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only
·
2015-06-03 16:00
LeetCode
[
LeetCode-JAVA
] Course Schedule II
题目: There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have to first take course
·
2015-06-02 20:00
LeetCode
[
LeetCode-JAVA
] Minimum Size Subarray Sum 两种方法(O(n)、O(lgn))
题目: Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn't one, return 0 instead. For example,
·
2015-06-02 10:00
LeetCode
[
LeetCode-JAVA
] 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 get t. All occurrences of a chara
·
2015-06-02 10:00
LeetCode
[
LeetCode-JAVA
] Implement Trie (Prefix Tree)
题目: Implement a trie with insert, search, and startsWith methods. // Your Trie object will be instantiated and called as such:// Trie trie = new Trie();// trie.insert("somes
·
2015-06-02 10:00
LeetCode
[
LeetCode-JAVA
] 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
·
2015-06-01 11:00
LeetCode
[
LeetCode-JAVA
] Bitwise AND of Numbers Range
题目: Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. For example, given the range [5, 7], you should return 4.
·
2015-06-01 10:00
LeetCode
[
LeetCode-JAVA
] Number of Islands
题目: Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically.
·
2015-06-01 09:00
LeetCode
[
LeetCode-JAVA
] Word Break II
题目: Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences.
·
2015-05-26 10:00
LeetCode
上一页
1
2
3
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他