
刷题练习
文章平均质量分 52
slbyzdgz
这个作者很懒,什么都没留下…
展开
-
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 · 261 阅读 · 0 评论 -
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 · 407 阅读 · 0 评论 -
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 · 141 阅读 · 0 评论 -
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 · 208 阅读 · 0 评论 -
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 · 125 阅读 · 0 评论 -
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 · 139 阅读 · 0 评论 -
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 · 144 阅读 · 0 评论 -
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 · 133 阅读 · 0 评论 -
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 · 168 阅读 · 0 评论 -
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 · 126 阅读 · 0 评论 -
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 · 203 阅读 · 0 评论 -
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 · 137 阅读 · 0 评论 -
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 · 148 阅读 · 0 评论 -
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 · 229 阅读 · 0 评论 -
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 · 153 阅读 · 0 评论 -
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 · 223 阅读 · 0 评论 -
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 · 181 阅读 · 1 评论 -
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 · 153 阅读 · 0 评论 -
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 · 137 阅读 · 0 评论 -
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 · 153 阅读 · 0 评论 -
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 · 196 阅读 · 1 评论 -
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 · 170 阅读 · 0 评论 -
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 · 195 阅读 · 0 评论 -
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 · 177 阅读 · 0 评论 -
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 · 181 阅读 · 0 评论 -
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 · 153 阅读 · 0 评论 -
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 · 142 阅读 · 0 评论 -
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 · 184 阅读 · 0 评论 -
LeetCode---Move Zeroes、Third Maximum Number、Find All Duplicates in an Array、Find All Numbers Disappe
283.Move ZeroesGiven an arraynums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.Example:Input: [0,1,0,3,12]Output: [1,3,12,...原创 2019-06-26 21:50:47 · 141 阅读 · 0 评论 -
LeetCode---Pascal's Triangle II
Given a non-negativeindexkwherek≤33, return thekthindex row of the Pascal's triangle.Note that the row index starts from0.In Pascal's triangle, each number is the sum of the two numbers ...原创 2019-06-23 21:59:27 · 149 阅读 · 0 评论 -
LeetCode---Pascal's Triangle
Given a non-negative integernumRows, generate the firstnumRowsof Pascal's triangle.In Pascal's triangle, each number is the sum of the two numbers directly above it.Example:Input: 5Output:...原创 2019-06-23 21:43:19 · 167 阅读 · 0 评论 -
LeetCode---Rotate Array、Missing Number
189.Rotate ArrayGiven an array, rotate the array to the right byksteps, wherekis 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...原创 2019-06-25 19:55:57 · 186 阅读 · 0 评论 -
LeetCode---Contains Duplicate
217.Contains DuplicateGiven an array of integers, find if the array contains any duplicates.Your function should return true if any value appears at least twice in the array, and it should return...原创 2019-06-25 19:21:38 · 168 阅读 · 0 评论 -
斐波那契数列
题目描述菲波那契数列是指这样的数列:数列的第一个和第二个数都为1,接下来每个数都等于前面2个数之和。给出一个正整数K,要求菲波那契数列中第k个数是多少。输入描述:输入一行,包含一个正整数k。(0<k<47)输出描述:输出一行,包含一个正整数,表示菲波那契数列中第k个数的大小...原创 2019-02-24 21:56:50 · 496 阅读 · 0 评论 -
加法等式
原创 2019-02-24 21:23:57 · 309 阅读 · 0 评论 -
整数和
原创 2019-02-24 20:37:38 · 207 阅读 · 0 评论 -
TCP三次握手详解及释放连接过程
原文地址TCP报文的结构源端口和目的端口:各占2个字节,分别写入源端口号和目的端口号。 序号:占4个字节。序号使用mod运算。TCP是面向字节流的,在一个TCP连接中传送的字节流中的每一个字节都按顺序编号。故该字段也叫做“报文段序号”。 确认序号:占4个字节,是期望收到对方下一个报文段的第一个数据字节的序号。若确认序号=N,则表明:到序号N-1为止的所有数据都已正确收到。 数...转载 2019-01-25 15:57:57 · 588 阅读 · 0 评论 -
WEB SERVICE名词解释。JSWDL开发包的介绍。JAXP、JAXM的解释。SOAP、UDDI,WSDL解释。
原文地址Web ServiceWeb Service是基于网络的、分布式的模块化组件,它执行特定的任务,遵守具体的技术规范,这些规范使得Web Service能与其他兼容的组件进行互操作。JAXP(Java API for XML Parsing) 定义了在Java中使用DOM, SAX, XSLT的通用的接口。这样在你的程序中你只要使用这些通用的接口,当你需要改变具体的实现时候也不需要修改...转载 2019-01-25 15:34:45 · 649 阅读 · 0 评论 -
计算机网络--错题集2
123解析:CSMA/CD适用于有线网络,而CSMA/CA则广泛应用于无线局域网(具体原因请见王道2017版单科书P90)。其他选项关于CSMA/CD的描述都是正确的。45在星型拓扑结构中,网络中的各节点通过点到点的方式连接到一个中央节点(又称中央转接站,一般是集线器或交换机)上,由该中央节点向目的节点传送信息。中央节点执行集中式通信控制...原创 2019-01-24 21:12:50 · 251 阅读 · 0 评论 -
计算机网络---错题集1
12345http表示使用HTTP协议,底层才是TCP6C 全局模式(配置模式)从Console口或Telnet及AUX进入路由器时,首先要进行一般用户模式,在一般用户模式下,用户只能运行少数的命令,而且不能对路由器进行配置。在没有进行任何配置的情况下,缺省的路由器提示符为:Route>超级权限模式在缺省状态上,超...原创 2019-01-24 17:53:57 · 310 阅读 · 0 评论