自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(131)
  • 收藏
  • 关注

原创 LeetCode刷题记录

@[TOC](文章预览:)##两数之和给定一个整数数组 nums和一个整数目标值 target,请你在该数组中找出 和为目标值 target的那两个整数,并返回它们的数组下标。你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。你可以按任意顺序返回答案。示例1输入:nums = [2,7,11,15], target = 9输出:[0,1]解释:因为 nums[0] + nums[1] == 9 ,返回 [0, 1] 。解法:暴力解...

2021-12-10 18:02:59 166

原创 Android Stdio引入kotlin-android-extensions插件

在Activity中使用Toast<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">

2021-05-12 23:18:31 2815 6

原创 1到n!的和

sum = 0shu = int(input("请输入所求的一个数阶乘的累加和: "))for i in range(1, shu+1): s = 1 for j in range(2, i+1): s *= j sum += sprint("1!+2!+.....+%d!=%d" % (shu, sum))...

2019-10-29 18:46:20 338

原创 LeetCode---Jump Game、Jump Game II、Gas Station、Candy、Wiggle Subsequence

55.Jump GameGiven 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....

2019-08-22 21:37:54 189

原创 LeetCode---Arithmetic Slices、Partition Equal Subset Sum

413.Arithmetic SlicesA sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these ...

2019-08-21 21:47:56 127 1

原创 LeetCode---Perfect Squares、Longest Increasing Subsequence

279.Perfect SquaresGiven a positive integern, find the least number of perfect square numbers (for example,1, 4, 9, 16, ...) which sum ton.Example 1:Input: n = 12Output: 3 Explanation: 12...

2019-08-20 21:49:37 152 1

原创 LeetCode---Triangle、House Robber、House Robber II

120.TriangleGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], ...

2019-08-19 21:50:50 126

原创 LeetCode--- Maximum Subarray、Unique Paths、Unique Paths II、Minimum Path Sum、Climbing Stairs

53.Maximum SubarrayGiven an integer arraynums, find the contiguous subarray(containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4...

2019-08-19 20:42:49 136

原创 LeetCode---Maximum Binary Tree、Second Minimum Node In a Binary Tree、Search in a Binary Search Tree

654.Maximum Binary TreeGiven an integer array with no duplicates. A maximum tree building on this array is defined as follow:The root is the maximum number in the array. The left subtree is the ...

2019-08-15 20:44:59 125

原创 LeetCode---N-ary Tree Preorder Traversal、N-ary Tree Postorder Traversal、Merge Two Binary Trees

589.N-ary Tree Preorder TraversalGiven an n-ary tree, return thepreordertraversal of its nodes' values.For example, given a3-arytree:Return its preorder traversal as:[1,3,5,6,2,4].给...

2019-08-15 16:57:03 136

原创 LeetCode--- Diameter of Binary Tree、Maximum Depth of N-ary Tree、Average of Levels in Binary Tree

543.Diameter of Binary TreeGiven a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of thelongestpath between any two nodes in ...

2019-08-13 20:37:22 145

原创 LeetCode---Find Bottom Left Tree Value、Find Largest Value in Each Tree Row、Minimum Absolute Differen

513.Find Bottom Left Tree ValueGiven a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1 3Output:1Example 2:Input: 1 ...

2019-08-13 19:36:54 116

原创 LeetCode--- Path Sum III、Delete Node in a BST、Find Mode in Binary Search Tree

437.Path Sum IIIYou are given a binary tree in which each node contains an integer value.Find the number of paths that sum to a given value.The path does not need to start or end at the root or...

2019-08-13 16:57:07 168

原创 LeetCode--- Sum of Left Leaves、N-ary Tree Level Order Traversal

404.Sum of Left LeavesFind the sum of all left leaves in a given binary tree.Example: 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15...

2019-08-12 21:10:45 108

原创 LeetCode---Sum Root to Leaf Numbers、Binary Tree Preorder Traversal、Binary Tree Postorder Traversal

129.Sum Root to Leaf NumbersGiven a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which represents...

2019-08-12 20:43:49 94

原创 LeetCode---Binary Gap、Self Dividing Numbers、Reach a Number、Rectangle Overlap

868.Binary GapGiven a positiveintegerN, find and return the longest distance between two consecutive 1's in the binary representation ofN.If there aren't two consecutive 1's, return0.Exampl...

2019-08-07 19:58:04 143

原创 LeetCode---Rectangle Area、Reconstruct Original Digits from English、Valid Square、Sum of Square Number

223.Rectangle AreaFind the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Examp...

2019-08-06 22:23:31 116

原创 LeetCode---Intersection of Two Arrays、 II、Sort Colors、Largest Perimeter Triangle

349.Intersection of Two ArraysGiven two arrays, write a function to compute their intersection.Example 1:Input: nums1 = [1,2,2,1], nums2 = [2,2]Output: [2]Example 2:Input: nums1 = [4,9,...

2019-08-04 20:42:22 108

原创 LeetCode--Arranging Coins

441.Arranging CoinsYou have a total ofncoins that you want to form in a staircase shape, where everyk-th row must have exactlykcoins.Givenn, find the total number offullstaircase rows tha...

2019-08-01 20:26:52 110

原创 LeetCode--Power of Three、Integer Break、Count Numbers with Unique Digits、Valid Perfect Square

326.Power of ThreeGiven an integer, write a function to determine if it is a power of three.给定一个整数,写一个函数来判断它是否是 3的幂次方。class Solution(object): def isPowerOfThree(self, n): """ ...

2019-07-30 20:58:37 118

原创 LeetCode--Happy Number、Power of Two、 Add Digits、Ugly Number

202.Happy NumberWrite an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the s...

2019-07-27 21:14:45 146

原创 LeetCode--Add Binary、Sqrt(x)、Excel Sheet Column Title、Excel Sheet Column Number、Factorial Trailing Z

67.Add BinaryGiven two binary strings, return their sum (also a binary string).The input strings are bothnon-emptyand contains only characters1or0.Example 1:Input: a = "11", b = "1"Out...

2019-07-27 20:09:47 96

原创 LeetCode--Lowest Common Ancestor of a Binary Tree、Binary Tree Paths

236.Lowest Common Ancestor of a Binary TreeGiven a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to thedefinition of LCA on Wikipedia: “The lowest c...

2019-07-26 21:07:43 101

原创 LeetCode---Path Sum、Invert Binary Tree、Kth Smallest Element in a BST、最近公共祖先

112.Path SumGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note:A leaf is a node with no chil...

2019-07-26 19:55:14 107

原创 LeetCode---Convert Sorted Array to Binary Search Tree、Balanced Binary Tree、Minimum Depth of Binary T

108.Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is d...

2019-07-25 21:16:14 105

原创 LeetCode---Maximum Depth of Binary Tree、Construct Binary Tree from Preorder and Inorder Traversal

104.Maximum Depth of Binary TreeGiven 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.Not...

2019-07-23 22:04:49 115

原创 LeetCode---Binary Tree Inorder Traversal、Same Tree、Symmetric Tree、Binary Tree Level Order Traversal

94.Binary Tree Inorder TraversalGiven a binary tree, return theinordertraversal of its nodes' values.Example:Input: [1,null,2,3] 1 \ 2 / 3Output: [1,3,2]Follow up:Rec...

2019-07-23 21:17:27 97

原创 LeetCode--- Evaluate Reverse Polish Notation、Minimum Add to Make Parentheses Valid

150.Evaluate Reverse Polish NotationEvaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another expression....

2019-07-21 21:08:57 83

原创 LeetCode--- Baseball Game、Backspace String Compare、Remove Outermost Parentheses、1047

682.Baseball GameYou're now a baseball game point recorder.Given a list of strings, each string can be one of the 4 following types:Integer(one round's score): Directly represents the number o...

2019-07-20 21:43:48 118

原创 LeetCode--- Next Greater Element I、Next Greater Element II

496.Next Greater Element IYou are given two arrays(without duplicates)nums1andnums2wherenums1’s elements are subset ofnums2. Find all the next greater numbers fornums1's elements in the co...

2019-07-19 21:06:03 141

原创 LeetCode---Valid Parentheses、Min Stack、 Implement Stack using Queues

20.Valid ParenthesesGiven a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.An input string is valid if:Open brackets must be close...

2019-07-18 21:52:02 108

原创 LeetCode---Delete Node in a Linked List

237.Delete Node in a Linked ListWrite a function to delete a node (except the tail) in a singly linked list, given only access to that node.Given linked list --head =[4,5,1,9], which looks like...

2019-07-17 10:27:18 104

原创 LeetCode---Reverse Linked List、Reverse Linked List II、Remove Linked List Elements

206.Reverse Linked ListReverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can be reversed eit...

2019-07-16 11:25:57 110

原创 LeetCode---Linked List Cycle、Linked List Cycle II、Intersection of Two Linked Lists

141.Linked List CycleGiven a linked list, determine if it has a cycle in it.To represent a cycle in the given linked list, we use an integerposwhich represents the position (0-indexed)in the l...

2019-07-16 09:53:49 119

原创 LeetCode---Add Two Numbers、Remove Nth Node From End of List、 Partition List

2.Add Two NumbersYou 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 ...

2019-07-15 15:18:21 94

原创 LeetCode---Merge Two Sorted Lists、Remove Duplicates from Sorted List 、II

21.Merge Two Sorted ListsMerge 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-&gt...

2019-07-15 09:38:05 111

原创 操作系统问题小记1

操作系统是一种系统软件!死锁状态一定是不安全状态产生死锁的4个必要条件: 1.互斥条件 2.请求和保持条件 3.不可抢占 4.循环等待条件预防死锁主要分为三种: 1.破坏请求和保持条件 2.破坏不可抢占条件 3.破坏循环等待条件避免死锁同样属于事先预防的策略,但并不是事先采取某种限制措施,破坏产生思索的必...

2019-07-12 22:43:56 108

原创 LeetCode--- Squares of a Sorted Array、Find Common Characters

977.Squares of a Sorted ArrayGiven an array of integersAsorted in non-decreasing order,return an array of the squares of each number,also in sorted non-decreasing order.Example 1:Input: [-...

2019-07-12 21:21:47 99

原创 LeetCode---Valid Mountain Array、Sort Array By Parity II

941.Valid Mountain ArrayGiven an arrayAof integers, returntrueif and only if it is avalid mountain array.Recall that A is a mountain array if and only if:A.length >= 3 There exists som...

2019-07-11 08:44:56 96

原创 LeetCode---Largest Number At Least Twice of Others、Toeplitz Matrix、Positions of Large Groups

747.Largest Number At Least Twice of OthersIn a given integer arraynums, there is always exactly one largest element.Find whether the largest element in the array is at least twice as much as ev...

2019-07-08 22:29:00 109

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除