自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Number of 1 Bits

191.Number of 1 BitsWrite a function that takes an unsigned integer and returnthe number of '1'bits it has (also known as theHamming weight).Example 1:Input: 0000000000000000000000000000...

2019-03-28 10:04:50 187

原创 Excel Sheet Column Number

171.Excel Sheet Column NumberGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ... Z -&g...

2019-03-28 09:43:15 186

原创 Search in Rotated Sorted Array

33.Search in Rotated Sorted ArraySuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e.,[0,1,2,4,5,6,7]might become[4,5,6,7,0,1,2]).You are given...

2019-03-22 16:15:17 195

原创 Unique Binary Search Trees II

95.Unique Binary Search Trees IIGiven an integern, generate all structurally uniqueBST's(binary search trees) that store values 1 ...n.Example:Input: 3Output:[ [1,null,3,2], [3,2,...

2019-03-22 15:43:26 130

原创 Decode Ways

91.Decode WaysA message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given anon-emptystring containing only...

2019-03-20 11:22:08 129

原创 Minimum Path Sum

64.Minimum Path SumGiven amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:You can only move eit...

2019-03-19 17:14:04 86

原创 Unique Paths II

63.Unique Paths IIA robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robo...

2019-03-19 15:36:06 90

原创 Unique Paths

62.Unique PathsA robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is t...

2019-03-19 11:58:55 92

原创 Longest Palindromic Substring

5.Longest Palindromic SubstringGiven a strings, find the longest palindromic substring ins. You may assume that the maximum length ofsis 1000.Example 1:Input: "babad"Output: "bab...

2019-03-19 11:33:00 107

原创 Min Cost Climbing Stairs

746.Min Cost Climbing StairsOn a staircase, thei-th step has some non-negative costcost[i]assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find...

2019-03-15 22:24:35 98

原创 Range Sum Query - Immutable

303.Range Sum Query - ImmutableGiven an integer arraynums, find the sum of the elements between indicesiandj(i≤j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -...

2019-03-14 21:56:51 115

原创 House Robber

198.House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is ...

2019-03-14 21:23:18 100

原创 Two Sum IV - Input is a BST

653.Two Sum IV - Input is a BSTGiven a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.Example 1:...

2019-03-14 20:48:51 96

原创 Average of Levels in Binary Tree

637.Average of Levels in Binary TreeGiven a non-empty binary tree, return the average value of the nodes on each level in the form of an array.Example 1:Input: 3 / \ 9 20 / \...

2019-03-14 18:02:23 129

原创 Path Sum III

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...

2019-03-14 17:57:26 95

原创 最大字段和

Given 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],Output: 6Explanati...

2019-03-08 09:43:20 201

原创 Sum of Left Leaves

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...

2019-03-07 21:54:46 175

原创 Subtree of Another Tree

572.Subtree of Another Tree判断一棵树是否为另外一颗树的子树。1、最开始的思路就是比较每个节点,判断其对应的树是不是和另外一棵树相等。那如何去比较每个点呢。一开始没想出来,其实就是写一个tranverse函数,每次判断当前节点耳朵树,以及其左子树,以及其右子树,用或连接,递归。//对每一个节点都求一次,两棵树是不是相等class Soluti...

2019-03-07 17:01:39 128

原创 Binary Tree Paths

257.Binary Tree PathsGiven a binary tree, return all root-to-leaf paths.Note:A leaf is a node with no children.Example:Input: 1 / \2 3 \ 5Output: ["1->2->5", "1-&g...

2019-03-07 14:56:25 115

原创 Binary Tree Tilt

563.Binary Tree TiltGiven a binary tree, return the tilt of thewhole tree.The tilt of atree nodeis defined as theabsolute differencebetween the sum of all left subtree node values and the su...

2019-03-07 11:19:32 157

原创 Diameter of 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 ...

2019-03-07 10:24:44 83

原创 Lowest Common Ancestor of a Binary Search Tree

235.Lowest Common Ancestor of a Binary Search TreeGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wi...

2019-03-07 10:21:34 102

原创 Invert Binary Tree

#226.Invert Binary Tree递归反转,申明一个temp结点/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) :...

2019-03-07 10:19:04 79

原创 Majority Element

#169Majority ElementGiven an array of sizen, find the majority element. The majority element is the element that appearsmore than⌊ n/2 ⌋times.You may assume that the array is non-empty and th...

2019-03-05 21:11:21 114

原创 Excel Sheet Column Title

168.Excel Sheet Column TitleGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 ...

2019-03-05 20:01:47 142

原创 Two Sum II - Input array is sorted

#167Two Sum II - Input array is sortedGiven an array of integers that is alreadysorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum ...

2019-03-05 17:16:34 90

原创 Intersection of Two Linked Lists

#160Intersection of Two Linked Lists求两个链表的公共节点。1、分别遍历两个链表,求各自长度。然后求长度差,并让长的先走长度差这么多步,然后同时开始走,判断每个结点是否相等。(考虑到公共节点之后的每个结点一定是相等的,所以两个有公共节点的链表一定是前面不同。)class Solution {public: ListNode *get...

2019-03-05 15:54:14 109

原创 sklearn之adaboost

# -*- coding: utf-8 -*-import pandasimport numpy as npimport matplotlib.pyplot as pltfrom sklearn.ensemble import AdaBoostClassifierfrom sklearn.tree import DecisionTreeClassifierfrom sklear...

2019-03-01 10:13:29 273

原创 盛最多水的容器

#20 盛最多水的容器题目描述:给定n个非负整数a1,a2,...,an,每个数代表坐标中的一个点(i,ai) 。在坐标内画n条垂直线,垂直线i的两个端点分别为(i,ai) 和 (i, 0)。找出其中的两条线,使得它们与x轴共同构成的容器可以容纳最多的水。说明:你不能倾斜容器,且n的值至少为 2。输入: [1,8,6,2,5,4,8,3,7]...

2019-02-28 22:19:10 103

原创 删除排序数组中的重复项

#20 删除排序数组中的重复项题目描述:给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。给定数组 nums = [1,1,2], 函数应该返回新的长度 2, 并且原数组 nums 的前两个元素被修改为 1,2,你不需要考虑数组中超出...

2019-02-28 21:17:48 75

原创 有效的括号

#20 有效的括号题目描述:给定一个只包括'(',')','{','}','[',']'的字符串,判断字符串是否有效。有效字符串需满足:左括号必须用相同类型的右括号闭合。左括号必须以正确的顺序闭合。注意空字符串可被认为是有效字符串。输入: "()"输出: true输入: "()[]{}"输出: true输入: "(]"输出: false输入: "([)...

2019-02-28 20:55:35 126

转载 BT,GBDT相关博客

https://blog.csdn.net/weixin_28750267/article/details/81056866

2019-02-28 17:26:38 2851

原创 Longest Common Prefix

#14 Longest Common Prefix最大公共前缀。注意不是字符串,是前缀,因此会方便很多。如输入["flower","flow","flight"],返回字符串"fl";若没有,则返回空字符串。1、对所有字符串二分查找公共字符串+递归。去找前面一半的公共字符串和后面一般的公共字符串,再去找他们的公共字符串。以此不断二分下去,递归查找。最后肯定归结到判断2个字符串的...

2019-02-25 16:12:02 281

原创 Roman to Integer

#13 Roman to Integer罗马数恢复成整数。其实就是把几个特例写出来就可以,否则就加上去。注意因为遇到了I就+1,因此判断其后若跟着IV,则再+3而不是+4,其他同理。class Solution {public: int romanToInt(string s) { if(s.size()==0) return 0; int nu...

2019-02-25 15:53:51 83

原创 Palindrome Number

#9 Palindrome Number判断回文数。1、上一题就做过反转一个数,因此第一个思路就是反转数,如果和原数相等则为回文数。class Solution {public: bool isPalindrome(int x) { if(x<0) return 0; int originNum=x; int revNu...

2019-02-25 15:51:03 86

原创 Reverse Integer

#7 Reverse Integer反转数字。基本思路就是利用求余%和求商/两个计算。每次计算完的余在新的循环次数里面要乘以10,再加上新的余。利用商去更新每次数。同时考虑到32bit有无溢出。C++的<stdint.h>里面定义好了INT32_MAX和INT32_MIN。当然INT64_MAX也有。int64_t 其实就相当于long long; int32_t就是int...

2019-02-25 15:45:10 82

原创 Two Sum

前天开始刷leetcode,所以打算把代码和一些思路写在这里吧。本身自己就是菜鸟,就从easy开始做,大部分都是可以直接想到思路的。先把这几天的上传上来。#1Two Sum给出整型数组和一个数,找到数组中两个相加为该数的不同数的索引,答案唯一。1、暴力法暴力法就是逐个去遍历该元素和后面的元素之和,找到则返回即可。class Solution {public: v...

2019-02-25 15:36:45 94

原创 信号DOA估计

DOA估计(或波达方向估计):将接受信号进行空间傅里叶变换(空间傅里叶变换和离散时间傅里叶变换的区别是,空间傅里叶变换的求和是对阵元空间位置m,而时域傅里叶变换的求和变量时离散时间n),进而取模的平方得到空间谱,估计出信号的到达方向(空间谱的最大值对应的相位φ,再根据定义φ=2πdsinθ/λ,计算θ)。1、概念假设均匀线阵,空间仅有一个信号源,则接受信号可以表示为:               ...

2018-07-09 12:05:12 31874 5

原创 卡尔曼滤波估计线性预测器最优权值

                卡尔曼滤波在维纳滤波中的应用考虑到最优权值是一个常值向量,因此状态方程为w(n)=w(n-1)观测方程就是由滤波器的最优滤波误差推导出:d(n)=uT(n)w*(n)+e(n)然后对应到观测方程和状态方程 仿真时的权向量初始值为[0 0]T,估计误差相关矩阵P的初始值为I;假设信号u(n)由一个四阶AR模型产生:u(n)-1.6u(n-1)+1.46u(n-2)-0...

2018-07-09 11:33:33 2365

原创 RLS实现求解最小二乘确定性正则方程

RLS算法:递归最小二乘算法,使用迭代的方法求解最小二乘的确定性正则方程(奇异值分解也可以)。在用RLS时,数据矩阵会进一步得到扩充,将每次观测数据都放进来,而不是像奇异值分解只将每个滤波器都有数据时作为开始。这里就不多写RLS的推导过程;大致写一些思路:根据扩展后的观测数据矩阵A,定义出随时间和样本两个变化的时间相关矩阵和时间互相关矩阵,代入确定性正则方程;考虑到离当前时刻近的观测值对相关矩阵和...

2018-07-09 11:13:48 3541

空空如也

空空如也

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

TA关注的人

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