
leetcode
SmallNancy
这个作者很懒,什么都没留下…
展开
-
leetCode :旋转数组--Rotate Array
题目描述Given an array, rotate the array to the right by k steps, where k is non-negative.就是将数组进行右旋转Example 1:Input: [1,2,3,4,5,6,7] and k = 3Output: [5,6,7,1,2,3,4]Explanation:rotate 1 steps to t...原创 2019-03-17 17:36:08 · 157 阅读 · 0 评论 -
Leetcode:Linked List Cycle--判断链表是否有环
题目描述:Given a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where ...原创 2019-03-17 17:42:57 · 278 阅读 · 0 评论 -
leetcode150 逆波兰表达式求值
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Note:Division between two integers sho...原创 2019-08-20 08:45:03 · 133 阅读 · 0 评论 -
leetcode845: 数组中最长的山脉(超简单做法)
题目描述:我们把数组 A 中符合下列属性的任意连续子数组 B 称为 “山脉”:B.length >= 3存在 0 < i < B.length - 1 使得 B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1](注意:B 可以是 A 的任意子数组,包括整个数组...原创 2019-08-20 09:33:10 · 213 阅读 · 0 评论 -
leetcode142有效的字母异位词
题目描述:Given two strings s and t , write a function to determine if t is an anagram of s.Example 1:Input: s = "anagram", t = "nagaram"Output: trueExample 2:Input: s = "rat", t = "car"Output: f...原创 2019-08-24 09:55:01 · 143 阅读 · 0 评论 -
[leetcode 25] k个一组翻转链表
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the length of the linked list. If the number of n...原创 2019-08-24 14:36:41 · 141 阅读 · 0 评论 -
左右括号匹配问题--(判断栈是否为空)
栈空说明括号匹配。package com.leetcode;import java.util.ArrayDeque;import java.util.Deque;/** * @author YanQiKing * @date 2019/7/21 11:48 * 有效的括号 * 栈 */public class ValidParentheses { public st...原创 2019-08-24 15:18:37 · 390 阅读 · 0 评论 -
[leetcode142]环形链表------判断链表是否有环Ⅱ
题目描述:给定一个链表,返回链表开始入环的第一个节点。 如果链表无环,则返回 null。为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果 pos 是 -1,则在该链表中没有环。说明:不允许修改给定的链表解题代码:如果有环,返回相应的入环头节点 public ListNode detectCycle(ListNode head) {...原创 2019-08-30 20:26:15 · 184 阅读 · 0 评论