自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(56)
  • 资源 (1)
  • 收藏
  • 关注

原创 LeetCode:169. Majority Element

Given 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 the majority element alwa...

2019-07-10 15:29:58 183

原创 LeetCode:334. Increasing Triplet Subsequence

Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.Formally the function should:Return true if there existsi, j, ksuch thatarr[i]<arr[...

2019-07-09 22:18:43 231

原创 LeetCode:15. 3Sum

Given an arraynumsofnintegers, are there elementsa,b,cinnumssuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not cont...

2019-07-09 16:25:40 152

原创 LeetCode:129. Sum Root to Leaf Numbers

Given 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 the number123.Find the tota...

2019-07-07 16:37:40 109

原创 剑指offer:合并两个排序的链表

题目描述输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则。方法一:递归class Solution {public: ListNode* Merge(ListNode* pHead1, ListNode* pHead2) { if(!pHead1) return pHead2; if(!pHe...

2019-07-05 11:09:06 94

原创 剑指offer:调整数组顺序使奇数位于偶数前面

题目描述输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。方法一:class Solution {public: void reOrderArray(vector<int> &array) { int n = array....

2019-07-04 10:52:01 95

原创 LeetCode:873. Length of Longest Fibonacci Subsequence

A sequenceX_1, X_2, ..., X_nisfibonacci-likeif:n >= 3 X_i + X_{i+1} = X_{i+2}for alli + 2 <= nGiven astrictly increasingarrayAof positive integers forming a sequence, find theleng...

2019-06-24 21:02:18 126

原创 LeetCode:1094. Car Pooling

You are driving a vehicle thathascapacityempty seats initially available for passengers. The vehicleonlydrives east (ie. itcannotturn around and drive west.)Given a list oftrips,trip[i] = ...

2019-06-24 15:55:09 344

原创 LeetCode:1095. Find in Mountain Array

(This problem is aninteractive problem.)You may recall that an arrayAis amountain arrayif and only if:A.length >= 3 There exists someiwith0 < i< A.length - 1such that: A[0] &l...

2019-06-24 15:53:45 451

原创 LeetCode:1053. Previous Permutation With One Swap

Given an arrayAof positive integers (not necessarily distinct), return the lexicographically largest permutation that is smaller thanA, that can bemade with one swap(Aswapexchanges the position...

2019-06-24 15:16:04 184

原创 LeetCode:1014. Best Sightseeing Pair

Given an arrayAof positive integers,A[i]represents the value of thei-th sightseeing spot, and twosightseeing spotsiandjhave distancej - ibetween them.Thescoreof a pair (i < j) of si...

2019-06-24 10:21:37 251

原创 LeetCode:55. Jump Game

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

2019-06-21 16:25:42 96

原创 LeetCode:650. 2 Keys Keyboard(DP/递归)

Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step:Copy All: You can copy all the characters present on the notepad (partial copy ...

2019-06-12 15:36:13 390

原创 LeetCode:516. Longest Palindromic Subsequence(DP)

Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.Example 1:Input:"bbbab"Output:4One possible longest palindr...

2019-06-11 21:35:06 118

原创 LeetCode:1048. Longest String Chain(DP)

Given a list of words, each word consists of English lowercase letters.Let's sayword1is a predecessor ofword2if and only if we can add exactly one letter anywhere inword1to make it equal towo...

2019-06-11 20:44:38 547

原创 LeetCode:743. Network Delay Time

There areNnetwork nodes, labelled1toN.Giventimes, a list of travel times asdirectededgestimes[i] = (u, v, w), whereuis the source node,vis the target node, andwis the time it takes fo...

2019-06-10 21:44:17 111

原创 827. Making A Large Island

In a 2D grid of0s and1s, we change at most one0to a1.After, what is the size of the largest island?(An island is a 4-directionally connected group of1s).Example 1:Input: [[1, 0], [0, 1]]...

2019-06-10 17:01:43 212

原创 LeetCode:96. Unique Binary Search Trees

Givenn, how many structurally uniqueBST's(binary search trees) that store values 1 ...n?Example:Input: 3Output: 5Explanation:Given n = 3, there are a total of 5 unique BST's: 1 ...

2019-03-18 15:10:14 127

原创 LeetCode:890. Find and Replace Pattern

You have a list ofwordsand apattern, and you want to know which words inwordsmatches the pattern.A word matches the pattern if there exists a permutation of letterspso that after replacing eve...

2019-03-14 22:15:24 117

原创 LeetCode:168. Excel Sheet Column Title

Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -&gt; A 2 -&gt; B 3 -&gt; C ... 26 -&gt; Z 27 -&gt; AA 28 -&g...

2019-03-13 17:21:30 92

原创 LeetCode:949. Largest Time for Given Digits

Given an array of 4 digits, return the largest 24 hour time that can be made.The smallest 24 hour time is 00:00, and the largest is 23:59. Starting from 00:00, a time is larger if more time has ela...

2019-03-13 15:03:24 136

原创 LeetCode:409. Longest Palindrome

Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example"Aa"is not consi...

2019-03-08 15:00:59 83

原创 LeetCode:389. Find the Difference

题目:Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was...

2019-02-22 16:01:42 90

原创 LeetCode:953. Verifying an Alien Dictionary

题目:In an alien language, surprisingly they also use english lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters.Given a sequenc...

2019-02-14 15:24:18 151

原创 LeetCode:914. X of a Kind in a Deck of Cards

题目:In a deck of cards, each card has an integer written on it.Return true if and only if you can choose X &gt;= 2 such that it is possible to split the entire deck into 1 or more groups of cards, ...

2019-01-24 15:12:43 309

原创 LeetCode:849. Maximize Distance to Closest Person

题目:In a row of seats, 1 represents a person sitting in that seat, and 0represents that the seat is empty. There is at least one empty seat, and at least one person sitting.Alex wants to sit in t...

2019-01-23 15:28:32 113

原创 LeetCode:674. Longest Continuous Increasing Subsequence

题目(和830那题类似):Given an unsorted array of integers, find the length of longest continuousincreasing subsequence (subarray).Example 1:Input: [1,3,5,4,7]Output: 3Explanation: The longest continuo...

2019-01-23 10:24:28 103

原创 LeetCode:118. Pascal's Triangle

题目:Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.In Pascal's triangle, each number is the sum of the two numbers directly above it.Example:Input: 5Ou...

2019-01-23 10:06:31 79

原创 628. Maximum Product of Three Numbers

题目:Given an integer array, find three numbers whose product is maximum and output the maximum product.Example 1:Input: [1,2,3]Output: 6 Example 2:Input: [1,2,3,4]Output: 24 Note:...

2019-01-22 17:13:20 125

原创 LeetCode:830. Positions of Large Groups

题目:In a string S of lowercase letters, these letters form consecutive groups of the same character.For example, a string like S = "abbxxxxzyy" has the groups "a", "bb", "xxxx", "z" and "yy".

2019-01-22 16:22:11 138 2

原创 leetcode: 717. 1-bit and 2-bit Characters

题目:We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11).Now given a string represented by several bit...

2019-01-21 15:05:48 86

原创 单链表翻转 Python实现

#class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Nonecurr = headwhile curr.next != None: tmp = curr.next curr.next = tmp.next tmp.next...

2018-10-29 15:19:29 369

原创 pandas:匹配两个dataframe

有两个dataframe tb1,tb2,希望在tb1中找出包含tb2的行根据网站https://stackoverflow.com/questions/29464234/compare-python-pandas-dataframes-for-matching-rows的答案:One possible solution to your problem would be to use ...

2018-09-19 15:38:10 27531

原创 python:list的“+=”和“append”的区别

A minor detail to note is the difference between the "+=" and "append" when it comes to Python lists. In many applications the two are interchangeable, but here they are not. If you are appending a li...

2018-09-13 20:56:26 1534

原创 pandas:插入列

摘自:https://blog.csdn.net/ysh55024/article/details/81389410添加一列数据,,把dataframe如df1中的一列或若干列加入另一个dataframe,如df2思路:先把数据按列分割,然后再把分出去的列重新插入df1 = pd.read_csv('example.csv')(1)首先把df1中的要加入df2的一列的值读取出来,...

2018-09-05 21:19:12 10027

原创 pandas:read_csv

设置读入文件的第一列为index,第一行为headerdata=pd.read_csv('data.csv', index_col=0, header=0) 

2018-09-05 17:47:59 326

原创 Kaggle:House Prices: Advanced Regression Techniques--数据缺失值处理

数据缺失值处理1.导入数据import pandas as pdX = pd.read_csv('train.csv')Y = pd.read_csv('test.csv')2.查看数据X.info()3.计算每列的缺失率,并按缺失率降序排序null_num = X.shape[0] - X.count() #计算每列的缺失数null_num_rate = ...

2018-09-05 16:56:04 440

原创 pandas:get_dummies()函数

pandas.get_dummies(data, prefix=None, prefix_sep='_', dummy_na=False, columns=None, sparse=False, drop_first=False, dtype=None)[source]Convert categorical variable into dummy/indicator variables,dummy...

2018-07-05 11:07:25 2850

原创 pandas: groupby()分组求平均值

两种方式都可以data.groupby('Pclass')['Fare'].mean()data.groupby('Pclass').mean()['Fare']

2018-07-01 15:47:00 50953 4

原创 LeetCode:712. Minimum ASCII Delete Sum for Two Strings(动态规划)

Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal.Example 1:Input: s1 = "sea", s2 = "eat"Output: 231Explanation: Deleting "s" from "sea" adds the AS...

2018-06-30 12:00:08 113

韩顺平java从入门到精通视频教程(全94讲)学习笔记整理(齐全).doc

韩顺平java从入门到精通视频教程(全94讲)学习笔记整理(齐全).doc

2015-12-19

空空如也

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

TA关注的人

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