自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 大数乘法

用字符串实现两个大数乘法#include <iostream>#include <string.h> using namespace std; void multiply(const char *a,const char *b); int main(){ //cout<<"hicjiajia"<<endl; string num1,num2; // 初始状态用string

2016-03-26 10:23:29 283

转载 机器学习10大经典算法

1、C4.5机器学习中,决策树是一个预测模型;他代表的是对象属性与对象值之间的一种映射关系。树中每个节点表示某个对象,而每个分叉路径则代表的某个可能的属性值,而每个叶结点则对应从根节点到该叶节点所经历的路径所表示的对象的值。决策树仅有单一输出,若欲有复数输出,可以建立独立的决策树以处理不同输出。从数据产生决策树的机器学习技术叫做决策树学习, 通俗说就是决策树。决策树学习也是数据挖掘中一个普通的方法。

2016-02-22 21:07:25 1127

原创 Recover Binary Search Tree

Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you devise a consta

2015-12-03 09:49:51 366

原创 Unique Binary Search Trees

Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \ /

2015-11-30 10:00:47 370

原创 Restore IP Addresses

Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order does not m

2015-11-28 16:16:42 302

原创 Decode Ways

A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total number of w

2015-11-24 10:58:14 275

转载 Find the Duplicate Number

Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, fin

2015-11-23 10:39:18 360

转载 gray code

The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray

2015-11-16 10:26:01 295

原创 Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of the

2015-11-15 21:53:20 275

原创 Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1->1->2->

2015-11-12 11:12:53 273

原创 Word Search

Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neig

2015-11-11 21:22:29 349

原创 Subsets and Subsets II

Given a set of distinct integers, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For example,If nums

2015-11-11 20:37:48 301

原创 Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]直接能想到的还是通过递归来

2015-11-06 13:03:21 287

原创 Sort Colors

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0, 1,

2015-11-04 15:36:36 290

转载 Simplify Path

Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"class Solution {public: string simplifyPath(string path) {

2015-11-04 11:10:50 243

原创 Unique Paths and Unique Paths II

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the botto

2015-10-28 09:47:52 216

转载 Permutation Sequence

The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""312""321

2015-10-27 10:42:32 235

原创 Spiral Matrix

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[[ 1, 2, 3 ],[ 4, 5, 6 ],[ 7, 8, 9 ]]You should retu

2015-10-25 11:11:56 259

原创 Maximum Subarray

Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] has the

2015-10-25 10:27:38 251

原创 N-Queens and N-Queens II

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle.Eac

2015-10-23 20:42:50 286

原创 Pow(x, n)

Implement pow(x, n).实现一个浮点数幂运算的问题。这里不需要考虑越界的问题,指数是int,也不需要处理分数指数的问题。为了减小运行时间,我们采取折半相乘的方案,用递归来实现。用枚举的方法也可以实现,但是代码会比较长。class Solution {public: double myPow(double x, int n) { if(x==0) //底数为

2015-10-22 10:55:48 254

原创 Rotate Image

You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?这个题要求将矩阵顺时针旋转90度。矩阵的操作最好不要放在整体进行,这样比较好处理。这里我采取按圈处理的方式,change()负责

2015-10-21 10:57:10 253

原创 Permutations and Permutations II

Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].这道题目的要求是找出数组的全排列,并把所有的全排列

2015-10-20 10:59:05 386

原创 Multiply Strings

Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.这个题目看似是两个数的乘法,但我们并不能通过转换类型的方式来直接乘,因为用字符串存储是不存

2015-10-20 09:25:22 273

原创 Combination Sum and Combination Sum II

Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited number of t

2015-10-18 21:54:33 306

原创 Count and Say

The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as "one 2, then

2015-10-18 20:47:35 269

原创 树的子结构

输入两颗二叉树A,B,判断B是不是A的子结构。这个题看得出应该是用递归,但是情况比较多,还是要好好思考一下。代码如下:struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), r

2015-10-16 16:08:16 211

原创 Valid Sudoku and Sudoku Solver

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partially filled sudoku which

2015-10-15 10:04:27 220

原创 Next Permutation

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible orde

2015-10-13 15:27:43 361

原创 Divide Two Integers

Divide two integers without using multiplication, division and mod operator.If it is overflow, return INT_MAX.乘法实际上也是加法的重复操作,而除法则是乘法的逆操作。因此,在不用乘法,除法和模运算的情况下,我们用加法来代替除法操作。class Solution {public: i

2015-10-12 10:35:48 306

原创 Merge Two Sorted Lists and Merge k 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.这个题的思路还是比较清晰的。两个链表都已经排好序,首先,选择两个链表中头结点较小的作为结果的头结点。然后,依次比较当前

2015-10-05 21:18:44 273

原创 Swap Nodes in Pairs and Reverse Nodes in k-Group

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. You may not

2015-10-02 15:06:54 402

原创 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:"((()))", "(()())", "(())()", "()(())", "()()()"用栈可以判

2015-09-28 16:47:56 213

转载 关于CTEX处理参考文献编译出错的问题

使用Latex来排论文还是有不少细节比较头疼的。 用IEEEtran模板编译bib一直报错,想了半天也没找到问题。最后看了这篇帖子,是编译顺序的问题。工具贴,留着。使用的是IEEEtran的模板。因为该文章之前在latex中编译没有什么问题,但是这次对内容进行了一些改动,添加了一些引文,导致在WinEdit下的Latex编译和BibTex编译都在报错。改了一整天,一直都

2015-09-26 14:49:49 3618 1

原创 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 string "23"

2015-09-22 09:37:10 214

原创 3Sum, 3Sum Closest, 4 Sum

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:Elements in a triplet (a,b,c) must be in

2015-09-20 16:35:28 291

转载 二叉树遍历(前序、中序、后序)递归与非递归

二叉树的非递归遍历                                                            二叉树的非递归遍历         二叉树是一种非常重要的数据结构,很多其它数据结构都是基于二叉树的基础演变而来的。对于二叉树,有前序、中序以及后序三种遍历方法。因为树的定义本身就是递归定义,因此采用递归的方法去实现树的三种遍历不仅容易理

2015-09-19 20:49:26 314

原创 从尾到头打印链表

输入一个链表,从尾到头打印链表每个节点的值。可以用库函数解题。每次在vector的头部插入即可,没什么技术含量。代码如下:class Solution {public: vector<int> printListFromTailToHead(struct ListNode* head) { vector<int> result; while(head!=N

2015-09-18 10:07:41 226

原创 几个数组问题,持续更新

1.数组分段求最长给定一个长度为N(N>1)的整型数组A,可以将A划分成左右两个部分,左部分A[0..K],右部分A[K+1..N-1],K可以取值的范围是[0,N-2]。求这么多划分方案中,左部分中的最大值减去右部分最大值的绝对值,最大是多少?给定整数数组A和数组的大小n,请返回题目所求的答案。测试样例:[2,7,3,1,1],5返回:6总的思路还是依次变换k的值进行验证。我们知道,数组

2015-09-17 21:13:13 349

原创 IP地址划分

A类地址 A类地址的表示范围为:0.0.0.0~126.255.255.255,默认网络掩码为:255.0.0.0;A类地址分配给规模特别大的网络使用。A类网络用第一组数字表示网络本身的地址,后面三组数字作为连接于网络上的主机的地址。分配给具有大量主机(直接个人用户)而局域网络个数较少的大型网络。例如IBM公司的网络。B类地址 3.B类地址的表示范围为:128.0.0.0~191.255.25

2015-09-15 13:51:17 235

空空如也

空空如也

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

TA关注的人

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