![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
qq_34505594
这个作者很懒,什么都没留下…
展开
-
归并排序(递归与非递归写法)
递归版本:public static void merge(int[] arr, int L, int M ,int R){ int [] help = new int[R-L+1]; int p1 = L; int p2 = M; int i = 0; while(p1<=M&&p2<=R){ help[i++] = arr[p1]>arr[p2]?arr[p2++]:arr[p1++]; } while(p1<=M){原创 2020-05-24 18:01:50 · 165 阅读 · 0 评论 -
328.奇偶链表
给定一个单链表,把所有的奇数节点和偶数节点分别排在一起。请注意,这里的奇数节点和偶数节点指的是节点编号的奇偶性,而不是节点的值的奇偶性。请尝试使用原地算法完成。你的算法的空间复杂度应为 O(1),时间复杂度应为 O(nodes),nodes 为节点总数。示例 1:输入: 1->2->3->4->5->NULL输出: 1->3->5->2->4->NULL示例 2:输入: 2->1->3->5->6->原创 2020-05-10 18:27:30 · 139 阅读 · 0 评论 -
32-从上到下打印二叉树
从上到下打印出二叉树的每个节点,同一层的节点按照从左到右的顺序打印。例如:给定二叉树:[3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7返回:[3,9,20,15,7]提示:节点总数 <= 1000来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/cong-shang-dao-xia-da-yin-er-cha-shu-lcof著作...原创 2020-05-10 15:47:49 · 118 阅读 · 0 评论 -
81. 搜索旋转排序数组 II
假设按照升序排序的数组在预先未知的某个点上进行了旋转。( 例如,数组[0,0,1,2,2,5,6]可能变为[2,5,6,0,0,1,2])。编写一个函数来判断给定的目标值是否存在于数组中。若存在返回true,否则返回false。示例1:输入: nums = [2,5,6,0,0,1,2], target = 0输出: true示例2:输入: nums = [...原创 2020-04-27 14:50:44 · 100 阅读 · 0 评论 -
20. Valid Parentheses
Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of b...原创 2020-04-18 13:48:04 · 95 阅读 · 0 评论 -
19. Remove Nth Node From End of List
Given a linked list, remove then-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, t...原创 2020-04-18 13:07:51 · 115 阅读 · 0 评论 -
LeetCode 5 Longest Palindromic Substring
LeetCode 5. Longest Palindromic Substringhttps://www.zhihu.com/question/40965749https://www.felix021.com/blog/read.php?2040https://blog.csdn.net/ggggiqnypgjg/article/details/6645824Given a...原创 2020-04-08 14:45:00 · 91 阅读 · 0 评论 -
leetcode 15. 3Sum
Given an arraynumsofnintegers, are there elementsa,b,cinnumssuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not cont...原创 2020-04-08 01:13:33 · 87 阅读 · 0 评论 -
LeetCode-14 Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string"".Example 1:Input: ["flower","flow","flight"]Output:...原创 2020-04-07 23:58:55 · 145 阅读 · 0 评论 -
178. Rank Scores
Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ranking. Note that after a tie, the next ranking number should be the next consecutive integer value. ...原创 2019-08-11 21:21:17 · 109 阅读 · 0 评论 -
177. Nth Highest Salary
Write a SQL query to get thenthhighest salary from theEmployeetable.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+For example...原创 2019-08-10 22:19:53 · 91 阅读 · 0 评论 -
176 Second Highest Salary
Write a SQL query to get the second highest salary from the de >Employeede> table.+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+原创 2018-01-07 14:16:34 · 178 阅读 · 0 评论 -
175 Combine Two Tables(数据库)
175.Table: Person>+-------------+---------+| Column Name | Type |+-------------+---------+| PersonId | int || FirstName | varchar || LastName | varchar |+-------------+-------原创 2018-01-07 14:17:55 · 150 阅读 · 0 评论 -
7 Reverse Integer
7.Given a 32-bit signed integer, reverse digits of an integer.//JAVAclass Solution { public int reverse(int x) { long res=0,n=x; int result=0; if(x { n=0-x; while(n>0) {原创 2018-01-07 14:25:16 · 133 阅读 · 0 评论 -
9 Palindrome Number
9.Determine whether an integer is a palindrome. Do this without extra space.C语言bool isPalindrome(int x){ if(x return false; int res=0,n=x; while(n>0) { res=res*10+n%10; n=n/10; } return x==res;原创 2018-01-07 14:26:00 · 133 阅读 · 0 评论 -
2 Add Two Number C++、JAVA
2.You are given twonon-emptylinked lists representing two non-negative integers. The digits are stored inreverse orderand each of their nodes contain a single digit. Add the two numbers and retu原创 2018-01-07 14:26:46 · 184 阅读 · 0 评论 -
1 Two Sum
1.Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the s原创 2018-01-07 14:27:18 · 113 阅读 · 0 评论 -
21. Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output: 1-...原创 2019-08-19 21:08:27 · 78 阅读 · 0 评论 -
180. Consecutive Numbers
Write a SQL query to find all numbers that appear at least three times consecutively.+----+-----+| Id | Num |+----+-----+| 1 | 1 || 2 | 1 || 3 | 1 || 4 | 2 || 5 | 1 || 6 | ...原创 2019-08-19 22:03:20 · 76 阅读 · 0 评论 -
657.Judge Route Circle
Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the original place.The move sequence is repres原创 2018-01-07 14:13:35 · 117 阅读 · 0 评论