Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the target, whe...
分类:
其他好文 时间:
2014-06-09 23:14:45
阅读次数:
264
下面说说split函数的用法
def break_words(stuff):
"""This function will break up words for us."""
words = stuff.split(' ')#split('.',1) use '.' split one time
return words
def sort_words(wo...
分类:
编程语言 时间:
2014-06-08 18:19:21
阅读次数:
336
【题目】
Follow up for problem "Populating Next Right Pointers in Each Node".
What if the given tree could be any binary tree? Would your previous solution still work?
Note:
You may only use constant extra space.
For example,
Given the following binary tre...
分类:
其他好文 时间:
2014-06-08 15:46:22
阅读次数:
303
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
//这里写重写的方法 一定要retrun ...
分类:
其他好文 时间:
2014-06-08 10:39:02
阅读次数:
278
题意:贪吃蛇的题目
思路:BFS+状态的记录,坑了无数发,#include
#include
#include
using namespace std;
const int MAXN = 500000;
bool flag[8],vis[25][25],mp[21][21][16384];
int n,m,l;
int xx[4]={-1,0,1,0}; // up,right,dow,left...
分类:
其他好文 时间:
2014-06-08 10:13:19
阅读次数:
204
题目
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...
分类:
其他好文 时间:
2014-06-08 09:23:34
阅读次数:
230
Follow up for "Search in Rotated Sorted
Array":What ifduplicatesare allowed?Would this affect the run-time complexity?
How and why?Write a function to...
分类:
其他好文 时间:
2014-06-08 01:19:29
阅读次数:
320
PathsumDescription: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 equa...
分类:
其他好文 时间:
2014-06-08 01:11:46
阅读次数:
395
Follow up for "Unique Paths":Now consider if
some obstacles are added to the grids. How many unique paths would there be?An
obstacle and empty space i...
分类:
其他好文 时间:
2014-06-08 00:33:42
阅读次数:
339
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.Fo...
分类:
其他好文 时间:
2014-06-07 16:55:09
阅读次数:
173