自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(41)
  • 资源 (6)
  • 收藏
  • 关注

原创 [LeetCode 5.28] Counting Bits

Counting BitsGiven a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example 1:Input: 2Output: [0,1,1]Example 2:Input: 5Output: [0,1

2020-05-28 20:33:58 82

原创 [LeetCode 5.7] Cousins in Binary Tree

Cousins in Binary TreeIn a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1.Two nodes of a binary tree are cousins if they have the same depth, but have different parents.We are given the root of a binary tree

2020-05-28 10:01:29 140

原创 [LeetCode 5.27] Possible Bipartition

Possible BipartitionGiven a set of N people (numbered 1, 2, …, N), we would like to split everyone into two groups of any size.Each person may dislike some other people, and they should not go into the same group.Formally, if dislikes[i] = [a, b], it me

2020-05-28 09:13:38 98

原创 [LeetCode 5.6] Majority Element

Majority ElementGiven an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element always exist in the array.Example 1:Input:

2020-05-26 16:31:30 87

原创 [LeetCode 5.5] First Unique Character in a String

First Unique Character in a StringGiven a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.Note:You may assume the string contai

2020-05-26 16:07:53 88

原创 Python collections.Counter(s)

Python collections.Counter(s)统计字符串s中各个字符的个数s = "loveleetcode"# build hash map : character and how often it appearscount = collections.Counter(s)结果:

2020-05-26 16:03:46 1045

原创 [LeetCode 5.4] Number Complement

Number ComplementGiven a positive integer num, output its complement number. The complement strategy is to flip the bits of its binary representation.Example 1:Input: num = 5Output: 2Explanation: The binary representation of 5 is 101 (no leading zero

2020-05-26 15:33:14 94

原创 [LeetCode 5.3] Ransom Note

Ransom NoteGiven an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; otherwise, it will return false.Each letter i

2020-05-26 11:46:18 949

原创 [LeetCode 5.2] Jewels and Stones

Jewels and StonesYou’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels.The lett

2020-05-26 11:23:44 94

原创 [LeetCode 5.1] First Bad Version

First Bad VersionYou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions af

2020-05-26 11:13:48 83

原创 Python 字典(dict)的默认值(defaultdict)和排序(sorted)

Python 字典(dict)默认值defaultdictdefaultdict的作用是在于,当字典里的key不存在但被查找时,返回的不是keyError而是一个默认值from collections import defaultdictdic1 = defaultdict(int)dic2 = defaultdict(set)dic3 = defaultdict(list))print(dict1[1])print(dict2[1])print(dict3[1])输出:0set(

2020-05-25 18:53:53 4379

原创 [LeetCode 5.22] Sort Characters By Frequency

Sort Characters By FrequencyGiven a string, sort it in decreasing order based on the frequency of characters.Example 1:Input:"tree"Output:"eert"Explanation:'e' appears twice while 'r' and 't' both appear once.So 'e' must appear before both 'r' a

2020-05-25 18:42:46 91

原创 [LeetCode 5.23] Interval List Intersections

Interval List IntersectionsGiven two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order.Return the intersection of these two interval lists.(Formally, a closed interval [a, b] (with a <= b) denotes the set of r

2020-05-25 18:17:44 100

原创 [LeetCode 5.25] Uncrossed Lines

Uncrossed LinesWe write the integers of A and B (in the order they are given) on two separate horizontal lines.Now, we may draw connecting lines: a straight line connecting two numbers A[i] and B[j] such that:A[i] == B[j];The line we draw does not int

2020-05-25 17:48:42 283

原创 [LeetCode 4.29] Binary Tree Maximum Path Sum

Binary Tree Maximum Path SumGiven a non-empty binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must contain at

2020-05-25 12:29:57 60

原创 [LeetCode] Path Sum I/II/III 回溯算法全解

[LeetCode] Path Sum I/II/III 回溯算法全解回溯算法的框架:参考文章.解决一个回溯问题,实际上就是一个决策树的遍历过程。你只需要思考 3 个问题:1、路径:也就是已经做出的选择。2、选择列表:也就是你当前可以做的选择。3、结束条件:也就是到达决策树底层,无法再做选择的条件。result = []def backtrack(路径, 选择列表): if 满足结束条件: result.add(路径) return for

2020-05-23 22:20:36 141

原创 [LeetCode 4.27] Maximal Square

Maximal SquareGiven a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.Example:Input: 1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0Output: 4Python3 Solution:Time: O(mn), Space: O(mn)dp[i][j]表示m

2020-05-22 14:32:37 63

原创 [LeetCode 4.26] Longest Common Subsequence

Longest Common SubsequenceGiven two strings text1 and text2, return the length of their longest common subsequence.A subsequence of a string is a new string generated from the original string with some characters(can be none) deleted without changing the

2020-05-22 10:49:19 100

原创 [LeetCode 4.25] Jump Game

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.Determine if you are able to reach the last index.Example 1:I

2020-05-22 10:04:18 73

原创 [LeetCode 4.23] Bitwise AND of Numbers Range

Bitwise AND of Numbers RangeGiven a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.Example 1:Input: [5,7]Output: 4Example 2:Input: [0,1]Output: 0Python3 Solution:找出m和n的公共前缀c

2020-05-18 21:12:58 84

原创 [LeetCode 4.22] Subarray Sum Equals K

Subarray Sum Equals KGiven an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.Example 1:Input:nums = [1,1,1], k = 2Output: 2Constraints:The length of the array is in range [1, 20,0

2020-05-17 09:36:26 63

原创 [LeetCode 4.20] Construct Binary Search Tree from Preorder Traversal

Construct Binary Search Tree from Preorder TraversalReturn the root node of a binary search tree that matches the given preorder traversal.(Recall that a binary search tree is a binary tree where for every node, any descendant of node.left has a value &l

2020-05-17 09:00:08 78

原创 [LeetCode 4.18] Minimum Path Sum

Minimum Path SumGiven a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at any point in time.Example:Input:[ [1

2020-05-16 21:39:02 98

原创 [LeetCode 4.17] Number of Islands

Number of IslandsGiven 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. You may assume all four edges of the grid are all su

2020-05-16 18:01:12 114

原创 [LeetCode 4.16] Valid Parenthesis String

Valid Parenthesis StringGiven a string containing only three types of characters: ‘(’, ‘)’ and ‘*’, write a function to check whether this string is valid. We define the validity of a string by these rules:Any left parenthesis ‘(’ must have a correspond

2020-05-16 16:13:16 85

原创 [LeetCode 4.15] Product of Array Except Self

Product of Array Except SelfGiven an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Example:Input: [1,2,3,4]Output: [24,12,8,6]Constraint: It's g

2020-05-16 15:40:11 61

原创 [LeetCode 4.13] Contiguous Array

Contiguous ArrayExample 1:Example 2:Note:Python3 Solution:Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.Example 1:Input: [0,1]Output: 2Explanation: [0, 1] is the longest contiguous subarray with eq

2020-05-14 21:42:03 136

原创 [LeetCode 4.12] Last Stone Weight

Last Stone WeightWe have a collection of stones, each stone has a positive integer weight.Each turn, we choose the two heaviest stones and smash them together. Suppose the stones have weights x and y with x <= y. The result of this smash is:If x =

2020-05-14 20:54:21 111

原创 Python heapq堆的常用方法

Python heapq堆的常用方法heapq.heappush(heap, item)heapq.heapify(list)heapq.heappop(heap)heapq.heapreplace(heap.item)heapq.heappushpop(list, item)heapq.heappush(heap, item)heap为定义堆,item增加的元素>>> import heapq>>> h = []>>> heapq.heapp

2020-05-14 20:52:53 395

原创 [LeetCode 4.11] Diameter of Binary Tree

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 the longest path between any two nodes in a tree. This path may or may not pass through the root.Exampl

2020-05-14 16:04:45 78

原创 [LeetCode 4.10] Min Stack

Min StackDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack.pop() – Removes the element on top of the stack.top() – Get the top element.getMin() – Retrieve the minimum e

2020-05-14 15:31:57 63

原创 module 'itertools' has no attribute 'izip_longest'

将itertools.izip_longest(S, T)改为zip_longest(S, T)原因:izip()和izip_longest()是属于itertools库的一个函数,在Python3中已经取消,具体分析如下:https://blog.csdn.net/sinat_28576553/article/details/85136614

2020-05-14 15:12:15 826

原创 [LeetCode 4.9] Backspace String Compare

Backspace String CompareGiven two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character.Note that after backspacing an empty text, the text will continue empty.Example 1:Input: S = "ab#c",

2020-05-13 21:52:09 91

原创 [LeetCode 4.8]Middle of the Linked List

Middle of the Linked ListGiven a non-empty, singly linked list with head node head, return a middle node of linked list.If there are two middle nodes, return the second middle node.Example 1:Input: [1,2,3,4,5]Output: Node 3 from this list (Serializati

2020-05-13 20:52:05 76

原创 [LeetCode 4.7]Counting Elements

Counting ElementsGiven an integer array arr, count element x such that x + 1 is also in arr.If there’re duplicates in arr, count them seperately.Example 1:Input: arr = [1,2,3]Output: 2Explanation: 1 and 2 are counted cause 2 and 3 are in arr.Exampl

2020-05-13 20:35:00 121

原创 [April 6th]Group Anagrams

Group AnagramsGiven an array of strings, group anagrams together.Example:Input: ["eat", "tea", "tan", "ate", "nat", "bat"],Output:[ ["ate","eat","tea"], ["nat","tan"], ["bat"]]Note:All inputs will be in lowercase.The order of your output do

2020-05-13 20:27:13 68

原创 [April 5th]Best Time to Buy and Sell Stock II——Python3 Solution

Best Time to Buy and Sell Stock IISay you have an array prices 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 as many transactions as you like (i.e., buy one and sell one

2020-05-13 20:23:08 75

原创 [April 4th]Move Zeroes——Python3 Solution

Move ZeroesGiven an array nums, write a function to move all 0’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,0,0]Note:You must do this in-place without making a copy of t

2020-05-13 20:18:32 83

原创 [April 3th]Maximum Subarray——Python3 Solution

Maximum SubarrayGiven an integer array nums, 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],Output: 6Explanation: [4,-1,2,1] has the largest sum = 6.F

2020-05-13 20:15:16 94

原创 [April 2th]Happy Number——[Python3/C++ Solution]

Happy NumberWrite an algorithm to determine if a number n is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until

2020-05-13 18:33:40 126

直接序列扩频通信系统_VHDL代码及文档.zip

使用VHDL语言进行直接序列扩频通信系统的仿真,实现信源产生、解扰、交织、直扩、BPSK调制、解调、相关、解交织、解扰、判决等一系列功能。PS:有同学反映文件损坏,又重新上传了一遍

2019-02-21

MATLAB通信系统仿真代码

MATLAB数字通信仿真(0/1数据产生,16QAM调制,插值,成型滤波,匹配滤波,采样,16QAM解调,判决,误码率计算)

2019-01-26

4PSK和QPSK调制及成型滤波sinc

数字通信仿真MATLAB,4PSK和QPSK调制及成型滤波器sinc

2019-01-26

【MATLAB】利用FFT分析其频谱

利用MATLAB生成正弦信号并利用FFT对其频谱进行分析,并比较不同情况的异同

2019-01-26

【MATLAB代码】随机信号和高斯信号的生成及概率密度函数PDF的分析

利用MATLAB进行随机信号和高斯信号的生成及概率密度函数PDF的分析

2019-01-26

多线程优先级示例_赛马

多核课程 多线程优先级示例_赛马 通过例子来演示多线程优先级

2017-12-04

空空如也

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

TA关注的人

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