自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

  • 博客(28)
  • 资源 (1)
  • 收藏
  • 关注

原创 Leetcode (28) Longest Consecutive Sequence

Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is [1, 2, 3, 4].

2015-04-28 14:46:16 590

原创 LeetCode (27) Linked List Cycle (判断cycle存在、寻找cycle入口节点)

判断cycle存在Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?本题要求判断给定链表中是否存在循环。并且题目要求不要使用extra space,因此,我们就不能保存每一个结点的value,在遍历的时候判断是否是循环。这道题可以通过

2015-04-28 14:36:06 1668

原创 LeetCode (26) LRU Cache

题目描述Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if t

2015-04-26 11:50:56 944 2

原创 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.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.

2015-04-26 11:29:00 871

原创 LeetCode (24) Happy Number

题目描述Write an algorithm to determine if a number 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

2015-04-26 10:59:17 12577

原创 OpenCV保存成XML(FileStorage)和CSV(重载<<运算符)文件

XML文件(使用FileStorage类)使用OpenCV时不仅要保存影像结果,往往也需要保存中间的矩阵结果,而OpenCV的imwrite函数只支持CV8U类型的数据(使用OpenCV保存其他类型Mat的时候,程序不会报错,但是无法生成结果文件),因此会给工作带来很多不便。OpenCV在2.0以后的版本中提供了FileStorage类,供用户直接使用,保存为XML/YAML文件。保存XML保存示例

2015-04-25 21:24:49 8604 7

原创 LeetCode (23) 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 you

2015-04-24 20:20:42 2004 1

原创 LeetCode (22) 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

2015-04-22 16:18:41 817

原创 LeetCode (21) Find Minimum in Rotated Sorted Array (with/without duplicates)

题目描述Suppose a sorted array 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).Find the minimum element.这里需要理解一个概念什么为Rotated Sorted Array。根据题目描述,Rotated

2015-04-22 16:03:13 708

原创 LeetCode (20) house robber (数组不相邻元素最大值)

题目描述You 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 that adjacent ho

2015-04-22 15:48:51 3688

原创 LeetCode (19) 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-04-22 15:39:25 873

原创 LeetCode (18) Permutations I & 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-04-22 15:17:13 1363

原创 LeetCode (17) Clone Graph

题目描述Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ’s undirected graph serialization: Nodes are labeled uniquely.We use # as a separator for each node,

2015-04-18 22:31:40 450

原创 LeetCode (16) Valid Palindrome (回文)

题目描述Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example, “A man, a plan, a canal: Panama” is a palindrome. “race a car” is not a p

2015-04-18 22:20:29 899

原创 LeetCode (15) Flatten Binary Tree to Linked List

题目描述Given a binary tree, flatten it to a linked list in-place.For example, Given The flattened tree should look like: 本题也是考察二叉树和指针操作的题目。题目要求将一棵二叉树拉平为一个链表 。链表通过树节点的右子树相连,且展开的顺序为原来树的前序遍历。实现思路:若节点n存

2015-04-18 22:16:43 873 1

原创 LeetCode (14) Plus One

题目描述Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.使用字符串表示数字,对数字进行“加1”操作,返回结

2015-04-18 22:08:38 1046

原创 LeetCode (13) Pascal's Triangle (杨辉三角 )

题目描述Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5, Return 从第三行开始,每行除了最左边和最右边两个数为1,其他数字都是上一行中相邻两个数字之和。根据上述规则可以写出下面的代码:class Solution {public: vecto

2015-04-18 22:01:22 1468

原创 LeetCode (12) Path Sum (二叉树路径和判断)

题目描述Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example: Given the below binary tree and sum

2015-04-18 21:58:17 947

原创 LeetCode (11) Number of 1 Bits

题目描述Write a function that takes an unsigned integer and returns the number of ’1’ bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11’ has binary representation 000000000

2015-04-18 21:51:10 1096

原创 Leetcode (10) Evaluate Reverse Polish Notation (计算逆波兰表示法多项式)

题目描述Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: [“2”, “1”, “+”, “3”,

2015-04-11 17:12:28 670

原创 Leetcode (9) Excel Sheet Column Number

题目描述Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> 28

2015-04-11 16:58:48 677

原创 Leetcode (8) Largest Number (剑指offer 33题 把数组排成最小的数)

题目描述Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result may be very la

2015-04-11 16:52:56 1803

原创 Leetcode (7) Integer to Roman

题目描述Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.博主表示第一次看的时候,没理解这个题目是啥意思,然后小查了一下才知道原来是要求我们把一个阿拉伯数字转换成罗马数字的形式。根据wiki查了一下罗马数字的规则:罗马数字共有7个,即 I

2015-04-11 16:36:19 571

原创 Leetcode (6) Remove Duplicates from Sorted Array

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

2015-04-11 16:26:12 551

原创 Leetcode (5) Same Tree

Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.简而言之,判断两棵二叉树是否相等,这里

2015-04-11 16:20:36 579

原创 Leetcode (4) Majority Element

题目描述Given 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 alw

2015-04-11 16:08:48 2226

原创 Leetcode (3) 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,

2015-04-11 15:22:54 580

原创 Leetcode (2) 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.简单的说就是将量和排好序的链表合并为一个链表。这道题的考察点为链表的操作。需要注意的是对链表有效性的判断

2015-04-11 15:00:29 688

模式识别 K均值

模式识别 K均值 c++实现模式识别

2011-12-18

空空如也

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

TA关注的人

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