自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 [leetcode 467]Unique Substrings in Wraparound String

Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this: "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....".Now we ha

2016-12-08 15:28:14 738

原创 [leetcode 463]Island Perimeter

You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely

2016-12-07 11:42:08 474

原创 [leetcode 464]Can I Win

In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach or exceed 100 wins.What if we change the game s

2016-11-29 11:39:29 1359

原创 [leetcode 452]Minimum Number of Arrows to Burst Balloons

There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordin

2016-11-23 14:15:57 542

原创 [leetcode 440]K-th Smallest in Lexicographical Order

Given integers n and k, find the lexicographically k-th smallest integer in the range from 1 to n.Note: 1 ≤ k ≤ n ≤ 109.Example:Input:n: 13 k: 2Output:10Explanation:The lexicograp

2016-11-10 21:46:50 1148

原创 [leetcode 441]Arranging Coins

ou have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins.Given n, find the total number of full staircase rows that can be formed.n

2016-11-10 18:05:29 434

原创 [leetcode 453]Minimum Moves to Equal Array Elements

Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.Example:Input:[1,2,3]

2016-11-10 17:47:58 395

原创 [曲苑杂谈]mac\windows phpstorm快捷键

下载链接:https://www.jetbrains.com/phpstorm/documentation/PhpStorm_ReferenceCard.pdf

2015-12-10 13:26:35 736

原创 [leetcode 290]Word Pattern

Given a pattern and a string str, find if str follows the same pattern.Examples:pattern = "abba", str = "dog cat cat dog" should return true.pattern = "abba", str = "dog cat cat fish" 

2015-10-07 14:13:27 655

原创 [leetcode 289]Game of Life

According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."Given a board with m

2015-10-07 13:52:54 2862

原创 [leetcode 287]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 element must exist. Assume that there is only one duplicate number,

2015-09-28 13:51:35 2161

原创 [leetcode 283]Move Zeroes

Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling you

2015-09-21 14:05:47 508

原创 [leetcode 282]Expression Add Operators

Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target value.

2015-09-21 11:26:42 1690

原创 [leetcode 279]Perfect Squares

Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n =

2015-09-11 09:50:12 843

原创 [leetcode 278]First Bad Version

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the

2015-09-08 22:05:24 649

原创 [leetcode 274 275]H-Index I II

274:Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wikipedia:

2015-09-06 16:58:21 632

原创 [leetcode 220]Contains Duplicate III

Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference between i an

2015-09-04 15:17:31 650

原创 [C++] 智能指针与循环引用

1、智能指针的出现      在我们写程序的时候总会遇到一些需要new的问题,在没有智能指针的时候,我们只能收到的去delete,一旦我们忘记就会出现内存泄漏的问题。智能指针的出现就是为了解决这一问题,让我们new的对象,能够在使用完毕之后自己delete,而不用我们手动delete。   2、智能指针的历史        1、auto_ptr(C++98)2、unique_ptr

2015-09-04 08:33:15 1397

原创 [数据结构]树状数组

刷题遇到树状数组,在这里做一下总结。    树状树状是一种数据结构,可以在o(logn)的时间内对元素进行修改和求和   1、根据元素数组构建树状数组        数组A为原数组,数组C为树状数组        C1 = A1     C2 = A1 + A2 C3 = A3 C4 = A1 + A2 + A3 + A4 C5 = A5 C6 = A5

2015-09-02 15:28:04 505

原创 [leetcode 222]Count Complete Tree Nodes

Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely fille

2015-09-02 11:20:12 442

原创 [leetcode 273]Integer to English Words

Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1.For example,123 -> "One Hundred Twenty Three"12345 -> "Twelve Thousand

2015-09-02 10:15:14 623

转载 进程通讯 线程同步方式

进程通讯的八种方式:  1、无名管道( pipe ):管道是一种半双工的通信方式,数据只能单向流动,而且只能在具有亲缘关系的进程间使用。进程的亲缘关系通常是指父子进程关系。2、高级管道(popen):将另一个程序当做一个新的进程在当前程序进程中启动,则它算是当前程序的子进程,这种方式我们成为高级管道方式。3、有名管道 (named pipe) : 有名管道也是半双工的通信方式,但是它允

2015-09-01 15:38:37 615

原创 [leetcode 257]Binary Tree Paths

Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]深度优先遍历,返回

2015-09-01 14:24:16 888

原创 [leetcode 258]Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has on

2015-09-01 14:19:37 846

原创 [leetcode 260]Single Number III

Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given

2015-08-31 15:42:22 1058

原创 [leetcode 263 264]Ugly Number I II

Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly si

2015-08-31 11:19:56 953 1

原创 [leetcode 268]Missing Number

Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.For example,Given nums = [0, 1, 3] return 2.Note:Your algorithm shoul

2015-08-31 09:52:38 584

原创 [leetcode 229]Majority Element II

Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.Hint:How many majority elements could it possibly

2015-08-10 15:28:00 593

原创 [python 笔记5]文件读写

1、定义 open(filename[,mode[,buffering]])  其中mode有: 2、读文件   1)读取整个文件test=open('input.txt','r')print test.read()   2)按字节数读取test=open('input.txt','r')print test.read(10)  3

2015-08-10 11:22:55 757

原创 [leetcode 230]Kth Smallest Element in a BST

Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements.Follow up:What if the

2015-08-09 11:13:25 737

原创 [leetcode 237]Delete Node in a Linked List

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with val

2015-08-09 08:31:02 570

原创 [数据结构]最小生成树

最小生成树:构造连通网的最小代价生成树1、Prim算法  Prim算法从图的顶点的方向出发,首先确定人一个定点,找到该定点到任意其他顶点的连通代价,然后根据新确定的节点更新到下一个节点的连通代价。  数据结构声明:  struct Graph{ int vertexes[MAX]; int arc[MAX][MAX]; int sum_vertexes

2015-08-09 08:25:34 747

原创 [数据结构]求二叉树的深度与宽度

二叉树数据结构声明:struct TreeNode{ int val; TreeNode *left; TreeNode *right;};  1、递归求二叉树深度  int getDepth(TreeNode *root){ if (root == NULL) { return 0; } re

2015-08-09 07:44:57 2863

原创 [leetcode 234]Implement Queue using Stacks

Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front of queue.peek() -- Get the front element.empty(

2015-08-08 20:18:37 616

原创 [leetcode 235]Lowest Common Ancestor of a Binary Search Tree

Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined betw

2015-08-08 17:32:51 459

原创 [leetcode 236]Lowest Common Ancestor of a Binary Tree

Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two node

2015-08-08 17:16:07 611

原创 [leetcode 238]Product of Array Except Self

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O

2015-08-07 17:35:20 546

原创 [leetcode 239]Sliding Window Maximum

Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window

2015-08-07 16:09:27 714

原创 [leetcode 240]Search a 2D Matrix II

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in

2015-08-07 11:22:51 578

原创 [python 笔记4]类(面向对象?)

1、定义   __metaclass__=typeclass Person: def __init__(self,name,age): self.name=name self.age=age def setName(self,name): self.name=name def getName(self): return self.name def setAge(sel

2015-08-07 11:12:09 676

空空如也

空空如也

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

TA关注的人

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