自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 LeetCode 之 Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.BST中深度的问题,我们可以递归(DFS),也可以迭代解决(BFS)

2015-11-30 22:20:58 206

原创 LeetCode 之 Intersection of Two Linked Lists

Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘

2015-11-30 20:07:03 232

原创 LeetCode 之 Factorial Trailing Zeroes

Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.最开始想到的是使用阶乘的方法:int trailingZeroes(int n) { if(n==0) retu

2015-11-26 22:29:25 238

原创 LeetCode 之 Pascal's Triangle

Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]class Solution {public:

2015-11-26 21:43:34 212

原创 LeetCode 之 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 house

2015-11-26 20:19:29 229

原创 LeetCode 之 Binary Tree Level Order Traversal I and II

Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree {3,9,20,#,#,15,7},

2015-11-25 16:08:25 236

原创 LeetCode 之 Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the f

2015-11-24 22:41:41 267

原创 LeetCode 之 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 singl

2015-11-23 22:08:57 237

原创 LeetCode 子 Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?这是一个很简单的动态规划问题:假设S(n)为n个台阶时的

2015-11-22 16:39:15 201

原创 LeetCode 之 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-11-21 18:31:52 281

原创 LeetCode 之 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-11-18 23:29:55 274

原创 LeetCode之 Nim Game

原题如下:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone

2015-11-18 22:57:43 228

原创 汉字转拼音

最近搞了一个DR100MKii来听歌,其他都挺好就是文件只支持日文和英文。每次往里面拷歌都要把中文的名字改为拼音,高帅富说干嘛不用Python写个脚本批量操作呀。确实可以这样,上网看了下,Python中有别人写的一个中文转拼音的库pypinyin。所以我就直接用了,下面是流程和代码。安装pypinyin:    pip install pypinyin代码:#-*-coding:utf

2015-11-07 22:39:45 416

空空如也

空空如也

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

TA关注的人

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