- 博客(137)
- 资源 (2)
- 收藏
- 关注
原创 Python 类方法 __init__ __new__ 方法 单件实现
class Test(object): def __init__(self): print 'init' self.init = 'self.init' @classmethod def getInstance(cls): if not hasattr(cls, 'instance'): cls.i
2013-03-19 16:12:25
789
原创 免费邮件、日历客户端解决方案
免费邮件、日历客户端解决方案首先说明,如果只需要免费的邮件客户端,而不需要日历客户端功能,那么网易闪电邮(http://fm.163.com/)是非常好的工具. 其优点是简单易用也够用,只需下载文件,双击即可安装;配置简单;支持主流邮箱。如果同时需要邮件、日历客户端的话,我的选择是使用Mozilla的一套方案。1. 首先安装Mozilla Thunderbird(http://www.
2013-02-27 13:38:30
1122
原创 Facebook 面试 FAQ
Facebook总部全年都在招人,中国的学生、工程师都可以在线投递简历,通过筛选之后会获得电话面试、现场面试的机会。另外,今年FB考虑到中国学生找工作的时间特点,在11月份组织工程师到中国来面试候选者。可以找人内推,几率可能会大点。主要招聘的是软件工程师,校招的页面是http://www.facebook.com/careers/university, 社会招聘的页面是http://www
2013-01-08 17:44:11
1493
1
原创 C# Dictionary 排序
Dictionary dicts = new Dictionary(); dicts["ma"] = 123; dicts["qing"] = 234; dicts["li"] = 12; dicts["ping"] = 534; dicts["zhang"] = 567;
2012-12-10 10:52:44
687
原创 Python Dict lambda 排序
nums = {'a':3, 'b':5, 'c':16, 'z':235, 'y':10}for key, val in sorted(nums.items(), key = lambda nums: nums[1], reverse = True): print key, str(val)Resultz 235c 16y 10b 5a 3
2012-12-10 10:42:07
932
原创 Trie树 键树应用
给一个字典,然后给定一个字符串,求字典中所有以该字符串为前缀的单词。会有多次查询,要求通过预处理建立一个查询结构。可假设字典仅含有小写字母。struct Node{ bool isTail; Node *child[26]; Node() { isTail = false; for(int i = 0; i < 26; ++i) child[i] = NULL;
2012-11-13 15:15:16
470
原创 重载输入输出运算符
class test{private: int x;public: friend istream& operator >>(istream & stream,test &other) { cout << "test input" << endl; other.x = 100; return stream; } friend ostream& operator <<(
2012-11-13 14:00:34
341
原创 找到符合签名的最小排列
You are given an array of n elements [1,2,....n]. For example {3,2,1,6,7,4,5}.Now we create a signature of this array by comparing every consecutive pir of elements. If they increase, write I else w
2012-11-13 13:50:37
481
原创 表达式求值 中缀树变后缀树
中缀表达式转化为后缀表达式中缀表达式和后缀表达式分别在向量IFX和PFX中,用栈S实现中缀式转为后缀式,对IFX中表达式从左到右扫描,设TOKEN是扫描读到的符号,转换算法可描述如下。 栈初始化从左向右扫描向量IFX,直到结尾: 1.从IPX中取出下一个TOKEN 2.CASE TOKEN OF '(': 将TOKEN压入栈S
2012-10-23 20:29:36
575
原创 哈夫曼树压缩 字符串编码
假设只有0-9这十个字符组成的字符串#define Size 10int freq[Size];string code[Size];string word;struct Node{ int id; int freq; Node *left; Node *right; Node(int freq_in):id(-1), freq(freq_in) { left = rig
2012-10-22 22:41:46
1167
原创 一个词典,一个字符矩阵,找出那些在字符举证中出现的单词
#define MAX 26struct Node{ bool isTail; char ch; Node* next[MAX]; Node():isTail(false), ch(' ') { for(int i = 0; i < MAX; ++i) next[i] = NULL; } Node(char ch_in):isTail(false), ch(ch_i
2012-10-22 21:25:31
731
原创 N个点的 费马点
平面中给定N个点的坐标(x, y), 找到离点(m, n)最近的一个点。 该点称为这N个点的 费马点。该问题是POJ上面的一个题目参考链接1参考链接2代码一#include #include #include using namespace std;#define MAX_NUM 128/* *http://www.programlife.net/poj-242
2012-10-22 16:25:11
1478
原创 LRU cache
struct Node{ int id; char val[100]; Node *prev; Node *next;};class DoubleLinkedList{public: DoubleLinkedList() { head = tail = NULL; size = 0; } int Size() { return size; } void
2012-10-21 16:16:54
335
原创 大整数 乘法
我的算法class Solution {public: string multiply(string num1, string num2) { int sa = num1.size(), sb = num2.size(); if(0 == sa || 0 == sb) return ""; vector res(sa + s
2012-10-17 22:35:27
347
原创 poj 1161 并査集
参考链接1参考链接2并査集。很多学生,每个学生可能属于一个或者多个社团。一个学生染病,其所在社团都有病。问一号学生得病了,一共有多少人得病。#include #include #include #include #include #include #include #include #include #include #include #inclu
2012-10-12 11:29:32
340
原创 heap sort 堆排序
堆排序 heap sort参考链接——1void Print(int arr[], int size){ if(NULL != arr) for(int i = 0; i < size; ++i) cout << arr[i] << ' '; cout << endl;}void MaxHeapify(int arr[], int idx, int size){
2012-10-10 16:43:39
287
原创 字符串中第一个只出现一次的字符
给定一个字符串,找出该字符串中第一个只出现一次的字符。char FirstNonRepeated(string& str){ //find the first char in str that appears only once //找到str中第一个只出现一次的字符 //假设只有ascii字符 short chars[256]; memset(chars, 0, 256);
2012-10-09 22:24:35
349
原创 单链表反转
struct Node{ int val; Node *next; Node(int val_in):val(val_in), next(NULL) { } Node(int val_in, Node *next_in):val(val_in), next(next_in) { }};Node* reverse(Node *head){ Node* ret = NUL
2012-10-09 17:32:48
305
原创 两链表相交,寻找第一个交点
struct Node{ int val; Node *next; Node(int val_in):val(val_in), next(NULL) { }};Node* getTail(Node* head, int& size){ size = 0; if(NULL == head) return NULL; while(NULL != head->next)
2012-10-09 17:23:27
385
原创 判断链表是否相交
struct Node{ int val; Node *next; Node(int val_in):val(val_in), next(NULL) { }};Node* getTail(Node* head){ if(NULL == head) return NULL; while(NULL != head->next) head = head->next;
2012-10-09 17:11:17
390
原创 判断链表是否有环
struct Node{ int val; Node *next; Node(int val_in):val(val_in), next(NULL) { }};bool hasCircle(Node* head){ if(NULL == head) return false; Node *fast = head, *slow = head; while(NULL
2012-10-09 17:03:55
464
转载 实现double sqrt(double num)
C语言实现sqrt的几种方法#include #include #include #include /** * * @brief 牛顿迭代法求解 * @param [in]要开方的数 * @return 开方后的结果 * */double sqrt_1(double dNum){ double dVal, dLastVal; assert(dNum > 1e-
2012-10-09 11:34:09
1709
原创 POJ 2528 离散化+线段树
题目大意:市长竞选,在一个墙上贴海报,每个海报都有起点和终点,问最后有几张海报是可见的。参考1参考2参考3参考4#include #include #include using namespace std;struct node{ int x; int num;}s[20004];//用于离散化,存储一个端点struct tree{ int l,
2012-10-04 12:33:22
610
原创 设计模式 - java与模式
软件系统开发的两个重点问题:可维护性与可重用性。面向对象系统的几大原则: 1. 开闭原则(OCP, Open-Closed Principle),对扩展开放,对修改关闭。 2. 里氏代换原则(LSP, Liskov Subsititution Principle),子类对象可以出现在任何父类对象出现的地方。 3. 依赖倒转原则(DIP, Dependence
2012-09-26 10:43:40
334
原创 面试题 - 1
1. 给一个字符串,返回true如果是个number,如果不是返回false. 这个有多少情况需要考虑?正负号;小数点;小于一的小数;科学计数法;三位一个逗号的形式 2. 给一个整数串,给一个整数,测试是否两个和是这个整数,这个是老题目了,但是他专门问了如果要测试非常快的话,怎么搞?3. An array with n elements which is K most so
2012-09-25 12:40:25
519
原创 LeetCode ZigZag Conversion
ZigZag ConversionThe string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A
2012-09-24 01:48:42
724
原创 LeetCode Word Search
Word SearchGiven 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
2012-09-24 01:38:55
983
原创 LeetCode Wildcard Matching
Wildcard MatchingImplement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The
2012-09-24 01:31:14
1090
原创 LeetCode Validate Binary Search Tree
Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with key
2012-09-24 01:24:25
1038
原创 LeetCode Valid Sudoku
Valid SudokuDetermine 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 pa
2012-09-24 01:13:54
1426
原创 LeetCode Valid Parentheses
Valid ParenthesesGiven a string containing just the characters '(', ')','{','}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[
2012-09-24 01:13:14
524
原创 LeetCode Valid Number
Valid NumberValidate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement t
2012-09-24 01:12:50
1323
1
原创 LeetCode Unique Paths II
Unique Paths IIFollow 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 is marked as 1 and 0 respect
2012-09-24 01:12:30
615
原创 LeetCode Unique Paths
Unique PathsA 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
2012-09-24 01:12:19
585
原创 LeetCode Valid Sudoku
Valid SudokuDetermine 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 pa
2012-09-24 01:11:32
45
原创 LeetCode Unique Binary Search Trees II
Unique Binary Search Trees IIGiven n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST'
2012-09-23 20:13:58
2048
原创 LeetCode Unique Binary Search Trees
Unique Binary Search TreesGiven 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
2012-09-23 20:04:49
719
原创 LeetCode Two Sum
Two SumGiven 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 ta
2012-09-23 19:50:48
676
原创 LeetCode Trapping Rain Water
Trapping Rain WaterGiven n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0
2012-09-23 19:38:00
1460
1
原创 LeetCode Text Justification
Text JustificationGiven an array of words and a length L, format the text such that each line has exactlyL characters and is fully (left and right) justified.You should pack your words in a gr
2012-09-23 19:24:46
1029
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人