上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页
摘要: Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit string "23"Output: ["ad", "ae", "af", "bd", "be", &q 阅读全文
posted @ 2013-09-20 17:19 懒猫欣 阅读(247) 评论(0) 推荐(0)
摘要: Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. Note:You are not suppose to use th 阅读全文
posted @ 2013-09-20 16:17 懒猫欣 阅读(132) 评论(0) 推荐(0)
摘要: Memset的原型是void *memset(void *s, char ch, size_t n);Memset是按字节赋值的,对char以外的类型赋0(00000000) -1(11111111)以外的值 阅读全文
posted @ 2013-09-20 15:46 懒猫欣 阅读(208) 评论(0) 推荐(0)
摘要: 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 palindrome.Note:Have you consider that the string might be empty? This is a good questi 阅读全文
posted @ 2013-09-20 02:05 懒猫欣 阅读(194) 评论(0) 推荐(0)
摘要: 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]. Return its length: 4.Your algorithm should run in O(n) complexity.unordered_set是C++自带的hash表class Solu 阅读全文
posted @ 2013-09-20 01:18 懒猫欣 阅读(241) 评论(0) 推荐(0)
摘要: C++Memset误区C++ 哈希表C++类型转换[转]C++ sizeofC++ 路径中\\与/ 阅读全文
posted @ 2013-09-19 16:47 懒猫欣 阅读(107) 评论(0) 推荐(0)
摘要: 从2011年开始,C++支持非排序的unordered_map和unordered_set(原先的map和set都是通过有序结构实现的)下面是一些性能上的测试#include#include#include#include#include#include#include#includeusing namespace std;int main(){ int n=100000; vector vec; srand(unsigned(time(0))); for(int i=0;i tm; unordered_sethm; start=clock(); for(int i=0;i#include#i 阅读全文
posted @ 2013-09-19 16:45 懒猫欣 阅读(426) 评论(0) 推荐(0)
摘要: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the total sum of all root-to-leaf numbers.For example, 1 / \ 2 3 The root-to-leaf path 1->2 represents the nu 阅读全文
posted @ 2013-09-19 15:29 懒猫欣 阅读(151) 评论(0) 推荐(0)
摘要: Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that:Only one letter can be changed at a timeEach intermediate word must exist in the dictionaryFor example, Given:start = "hit"end = "cog"dict = ["hot&quo 阅读全文
posted @ 2013-09-19 15:13 懒猫欣 阅读(199) 评论(0) 推荐(0)
摘要: Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediate word must exist in the dictionaryFor example, Given:start = "hit"end = "cog"dict = [" 阅读全文
posted @ 2013-09-18 21:42 懒猫欣 阅读(129) 评论(0) 推荐(0)
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 17 下一页