自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 C++中struct 与class 的比较

今天重温C++的基本知识,再次给自己清理了一下盲区,就是C++中的struct与class比较,在C++中struct进行了很大的扩充,功能变得更为复杂,这里就记录一下大神总结的区别。以下来自http://www.runoob.com/cplusplus/cpp-classes-objects.html的大神的笔记评论还有blog:http://blog.sina.com.cn/s/blog_67...

2018-03-15 21:43:52 504

原创 leetcode 29. Divide Two Integers

Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 解:这一题首先考虑一般情况,在不适用除法,乘法以及模运算的情况下进行整数的除法运算。可以想象使用位移运算。使用Leetcode上的讲解,假设15除以3,由于15大于

2017-08-15 19:15:59 377

原创 python利用网易云音乐接口搭建的音乐推荐,根据单曲歌名推荐相关用户喜爱的歌曲

一、网易云音乐的相关接口这边我想要的数据接口有:* 网易的搜索功能,根据歌名获取歌曲的id* 歌曲相关的评论用户接口* 用户的相关数据包括歌单或听歌记录,这边听歌记录的接口好像不能用,所以我就用的歌单接口关于每个接口大家可以自己F12网易官网看看是长什么样子,网易的新接口加密方式我也是在网上找的资料。这边就是接口部分的代码:import requestsimport

2017-07-29 17:34:27 4499 4

原创 leetcode 28. Implement strStr()

Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.解:KMP算法挺难理解的,看了几遍记住之后,做到这题只记得大体的思路但是算法细节有不理解了,先来个brute-force算法压压惊,再去看

2017-07-22 10:32:13 368

原创 leetcode 26. Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear onlyonce and return the new length.Do not allocate extra space for another array, you must do this in place with

2017-07-22 10:28:54 296

原创 leetcode 27. Remove Element

Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.Th

2017-07-21 19:37:06 262

原创 leetcode 25. Reverse Nodes in k-Group

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the length of the linked list. If the number o

2017-07-17 10:36:42 303

原创 leetcode 24. Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Yo

2017-07-16 21:31:52 222

原创 leetcode 23. Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.解:这一题没啥特别好的思路,想到的就是两两合并直至结束;还有一种跟两个链表合并差不多,把每个链表的表头元素进行比较,但是需要找到其中值最小的那个节点,感觉复杂度也不小,但是觉得可以利用一些特殊的数

2017-06-28 11:07:33 223

原创 leetcode 22. Generate Parentheses

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is: [ "((()))", "(()())", "(())()", "()(()

2017-06-28 10:43:38 226

原创 leetcode 21. Merge Two Sorted Lists

Merge 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解:简单题,合并两个有序的链表/** * Definition for singly-linked list.

2017-06-25 14:03:53 236

原创 leetcode 20. Valid Parentheses

Given a string containing just the characters '(', ')','{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all valid b

2017-06-25 12:26:40 231

原创 leetcode 19. Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the l

2017-06-25 11:42:47 256

原创 leetcode 18. 4Sum

Given an array S of n integers, are there elements a,b, c, and d in S such that a + b +c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The solution s

2017-06-18 21:01:05 354

原创 leetcode 17. Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit stri

2017-06-18 16:35:18 253

原创 leetcode 16. 3Sum Closest

Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly

2017-06-18 16:03:06 238

原创 leetcode 15. 3Sum

Given an array S of n integers, are there elements a,b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain du

2017-06-18 11:15:35 247

原创 leetcode 14. Longest Common Prefix

这题就是要求解所有字符串中最长前缀,可以将所有字符串的每一列进行遍历解:class Solution {public: string longestCommonPrefix(vector& strs) { string prefix = ""; int id1 = 0, id2 = 0; int len = strs.size();

2017-06-17 19:13:08 227

原创 leetcode 13. Roman to Integer

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.解:罗马数字的规则可以搜搜class Solution {public: int romanToInt(string s) { int roman[2

2017-06-15 20:07:51 243

原创 leetcode 12. Integer to Roman

Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.解:主要使用查表法代码:class Solution {public: string intToRoman(int num) { string

2017-06-10 15:37:21 239

原创 leetcode 11. Container With Most Water

Given n non-negative integers a1,a2, ..., an, where each represents a point at coordinate (i,ai). n vertical lines are drawn such that the two endpoints of linei is at (i, ai) and (i, 0). Find t

2017-06-10 15:20:35 222

原创 leetcode 10. Regular Expression Matching

Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input

2017-06-10 10:45:23 212

原创 Python爬虫股票评论,snowNLP简单分析股民用户情绪(草稿)

一、背景    股民是网络用户的一大群体,他们的网络情绪在一定程度上反映了该股票的情况,也反映了股市市场的波动情况。作为一只时间充裕的研究僧,我课余时间准备写个小代码get以下股民的评论数据,分析以下用户情绪的走势。这个博客还会修改,因为结果不准确,哈哈!二、数据来源    本次项目不用于商用,数据来源于东方财富网,由于物理条件,我只获取了一只股票的部分评论,没有爬取官方的帖子,都是获

2017-06-04 15:31:04 14313 5

原创 leetcode 9. Palindrome Number

Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting th

2017-06-02 11:36:22 284

原创 还原二叉树 (8分)

给定一棵二叉树的先序遍历序列和中序遍历序列,要求计算该二叉树的高度。输入格式:输入首先给出正整数N(\le≤50),为树中结点总数。下面两行先后给出先序和中序遍历序列,均是长度为N的不包含重复英文字母(区别大小写)的字符串。输出格式:输出为一个整数,即该二叉树的高度。输入样例:9ABDFGHIECFDHGIBEAC输出样例:5解

2017-05-30 20:55:32 534

原创 leetcode 8. String to Integer (atoi)

Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input case

2017-05-27 11:38:35 243

原创 leetcode 7. Reverse Integer

Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321 解:两种解法,时间复杂度要看测试样例。class Solution {public: int reverse(int x) { int y = 0, tmp = 0;

2017-05-23 17:28:07 286

原创 leetcode 6. ZigZag Conversion

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I

2017-05-17 21:48:31 232

原创 leetcode 5. Longest Palindromic Substring Add to List

Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example: Input: "babad"Output: "bab"Note: "aba" is also a valid answer.

2017-05-14 17:31:35 351

原创 05-树8 File Transfer (25分)

We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any computer

2017-05-14 14:34:34 372

原创 05-树7 堆中的路径 (25分)

将一系列给定数字插入一个初始为空的小顶堆H[]。随后对任意给定的下标i,打印从H[i]到根结点的路径。输入格式:每组测试第1行包含2个正整数NN和MM(\le 1000≤1000),分别是插入元素的个数、以及需要打印的路径条数。下一行给出区间[-10000, 10000]内的NN个要被插入一个初始为空的小顶堆的整数。最后一行给出MM个下标。输出格式:对输入中

2017-05-11 16:25:04 372

原创 leetcode 4. Median of Two Sorted Arrays

There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:nums1 =

2017-05-09 11:00:24 210

原创 leetcode 3. Longest Substring Without Repeating Characters

Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "

2017-05-07 20:52:21 200

原创 leetcode 2. Add Two Numbers

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i

2017-05-07 19:49:34 280

原创 04-树7 二叉搜索树的操作集

本题要求实现给定二叉搜索树的5种常用操作。函数接口定义:BinTree Insert( BinTree BST, ElementType X );BinTree Delete( BinTree BST, ElementType X );Position Find( BinTree BST, ElementType X );Position FindMin( BinTree BST

2017-05-05 22:20:01 295

原创 04-树6 Complete Binary Search Tree

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key.

2017-05-05 21:54:12 291

原创 04-树5 Root of AVL Tree (25分)

An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is

2017-05-03 23:03:23 522

原创 04-树4 是否同一棵二叉搜索树

给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。输入格式:输入包含若干组测试数据。每组数据的第1行给出两个正整数NN (\le 10≤10)和LL,分别是每

2017-05-02 09:28:47 523

转载 Manacher 最长回文子串

原文地址 https://segmentfault.com/a/11900000039142280. 问题定义最长回文子串问题:给定一个字符串,求它的最长回文子串长度。如果一个字符串正着读和反着读是一样的,那它就是回文串。下面是一些回文串的实例:12321 a aba abba aaaa tattarrattat(牛津英语词典中最长的回文单词)1. Brute-

2017-05-01 16:47:18 315

原创 03-树3 Tree Traversals Again (25分)

An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stac

2017-04-28 10:34:00 608

空空如也

空空如也

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

TA关注的人

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