
面试题
文章平均质量分 63
wjz748305545
这个作者很懒,什么都没留下…
展开
-
解释性语言和编译性语言
概念: 编译型语言:把做好的源程序全部编译成二进制代码的可运行程序。然后,可直接运行这个程序。 解释型语言:把做好的源程序翻译一句,然后执行一句,直至结束! 区别: 编译型语言,执行速度快、效率高;依赖编译器、跨平台性差些。如C、C++、Delphi、Pascal,Fortran转载 2014-02-26 21:36:52 · 702 阅读 · 0 评论 -
【DFS】Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combina原创 2014-03-20 21:03:56 · 437 阅读 · 0 评论 -
【DFS】Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()原创 2014-03-20 21:27:14 · 479 阅读 · 0 评论 -
【DFS】Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numb原创 2014-03-20 20:49:51 · 462 阅读 · 0 评论 -
字符串匹配的KMP算法
转自:http://www.cnblogs.com/reynold-lei/p/3370026.html字符串匹配的KMP算法举例来说,有一个字符串"BBC ABCDAB ABCDABCDABDE",我想知道,里面是否包含另一个字符串"ABCDABD"? 许多算法可以完成这个任务,Knuth-Morris-Pratt算法(简称KMP)是最常用的之一。它以三个发明者命名,转载 2014-04-16 22:06:16 · 455 阅读 · 0 评论 -
【DFS】Permutations
Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].解法一:DFS,递归时当前元素原创 2014-03-18 22:58:47 · 531 阅读 · 0 评论 -
【DFS】Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return [ ["aa","原创 2014-03-21 21:08:23 · 396 阅读 · 0 评论 -
计算阶乘n!末尾的0的个数
思路参考:http://www.oschina.net/code/snippet_112092_9454原创 2014-05-04 22:41:44 · 628 阅读 · 0 评论 -
LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if原创 2014-04-19 16:08:13 · 457 阅读 · 0 评论 -
【组合&元素和】3sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c原创 2014-04-04 21:17:04 · 424 阅读 · 0 评论 -
【组合&元素和问题】4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:Element原创 2014-04-04 20:42:31 · 616 阅读 · 0 评论 -
【位操作】Divide Two Integers
Divide two integers without using multiplication, division and mod operator.题意:不适用*public class Solution { public int divide(int a, int b) { if(a == 0 || b==0) return 0; if(b原创 2014-04-04 19:38:45 · 449 阅读 · 0 评论 -
【二分】Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array retur原创 2014-04-04 22:46:16 · 443 阅读 · 0 评论 -
【DP】Longest Repeated Sequence
描述You are given a sequence of integers, A = a1, a2, ... an. A consecutive subsequence of A (say ai, ai+1 ... aj) is called a "repeated sequence" if it appears more than once in A (there exists原创 2014-04-05 22:38:22 · 879 阅读 · 0 评论 -
【DFS】Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1].原创 2014-03-19 22:37:16 · 481 阅读 · 0 评论 -
【链表】删除链表中连续重复的节点
MS的一个面试题,删除链表中连续重复的节点,如1,2,2,2,3原创 2014-05-15 21:59:43 · 721 阅读 · 0 评论 -
【DFS】Letter Combinations of a Phone Number
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 st原创 2014-03-20 22:39:51 · 583 阅读 · 0 评论 -
【DFS】Subsets II
Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain dupli原创 2014-03-18 20:58:09 · 549 阅读 · 0 评论 -
c语言库函数
全手写char *strcpy(char* strDest, const char* strSrc)char *strcpy(char *strDest, const char *strSrc){ if(strDest==NULL || strSrc==NULL) return NULL; if(strDest == strSrc) return strDest; char *dest原创 2014-03-04 21:04:28 · 564 阅读 · 0 评论 -
strcpy
int main(){ char *s = "abc"; char d[3]; strcpy(d,s); printf("%s",d);//注意,可以正常输出abc,然后由于\0的关系发生了堆栈溢出,覆盖了返回地址,导致运行时错误,程序崩溃 return 0;}原创 2014-03-04 21:29:38 · 461 阅读 · 0 评论 -
【二叉树是否对称】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原创 2014-03-12 21:03:37 · 702 阅读 · 0 评论 -
二分查找分类总结
转自:http://blog.youkuaiyun.com/luckyxiaoqiang/article/details/8937978二分查找,最基本的算法之一,也是面试中常被考察的重点,因为基本的算法最能反映出一个人的基础是否扎实。本文对二分查找相关题目做一个总结。题目列表:1. 给定一个有序(非降序)数组A,求任意一个i使得A[i]等于target,不存在则返回-12.转载 2014-03-08 19:20:51 · 681 阅读 · 0 评论 -
链表分类总结
转自:http://blog.youkuaiyun.com/walkinginthewind/article/details/7393134链表是最基本的数据结构,面试官也常常用链表来考察面试者的基本能力,而且链表相关的操作相对而言比较简单,也适合考察写代码的能力。链表的操作也离不开指针,指针又很容易导致出错。综合多方面的原因,链表题目在面试中占据着很重要的地位。本文对链表相关的面试题做了较为全面转载 2014-03-08 19:25:37 · 3123 阅读 · 0 评论 -
二叉树的遍历-递归与非递归 - 海子
二叉树的遍历-递归与非递归 二叉树是一种非常重要的数据结构,很多其它数据结构都是基于二叉树的基础演变而来的。对于二叉树,有前序、中序以及后序三种遍历方法。因为树的定义本身就是递归定义,因此采用递归的方法去实现树的三种遍历不仅容易理解而且代码很简洁。而对于树的遍历若采用非递归的方法,就要采用栈去模拟实现。在三种遍历中,前序和中序遍历的非递归算法都很容易实现,非递归后序遍历实现转载 2014-03-08 20:39:04 · 596 阅读 · 0 评论 -
【二叉树先序遍历】Binary Tree Preorder Traversal
题意:二叉树的前序遍历这里先提供递归实现,后续补上public ArrayList preorderTraversal(TreeNode root) { if(root == null) return new ArrayList(); ArrayList list = new ArrayList(); ArrayList l原创 2014-03-08 18:07:41 · 669 阅读 · 0 评论 -
【DFS】Restore IP Addresses
Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["255.255.11.135", "255.255.111.35"]. (Order原创 2014-03-13 22:15:29 · 488 阅读 · 0 评论 -
轻松搞定面试中的二叉树题目
转自:http://blog.youkuaiyun.com/walkinginthewind/article/details/7518888树是一种比较重要的数据结构,尤其是二叉树。二叉树是一种特殊的树,在二叉树中每个节点最多有两个子节点,一般称为左子节点和右子节点(或左孩子和右孩子),并且二叉树的子树有左右之分,其次序不能任意颠倒。二叉树是递归定义的,因此,与二叉树有关的题目基本都可以用递归思想转载 2014-03-08 19:17:11 · 440 阅读 · 0 评论 -
【二叉树的后续遍历】Binary Tree Postorder Traversal
题意:二叉树的后续遍历这里先使用递归的形式实现,以后再数据结构中补上非递归实现,对边界条件的处理要想好!public ArrayList postorderTraversal(TreeNode root) { if(root == null) return new ArrayList(); ArrayList list = new ArrayList();原创 2014-03-08 18:02:43 · 707 阅读 · 0 评论 -
【二叉树中序遍历】Binary Tree Inorder Traversal
一、递归实现:public ArrayList inorderTraversal(TreeNode root) { ArrayList list = new ArrayList(); if(root == null) return list; ArrayList leftList = inorderTraversal(root.原创 2014-03-09 20:42:50 · 757 阅读 · 0 评论 -
Unique Binary Search Trees II
Given 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's shown below. 1 3原创 2014-03-13 20:09:32 · 431 阅读 · 0 评论 -
【二叉树层次遍历】Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20原创 2014-03-09 21:22:09 · 1027 阅读 · 0 评论 -
【DFS】Subsets
Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.For exa原创 2014-03-18 20:56:57 · 410 阅读 · 0 评论 -
【DFS】Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]原创 2014-03-18 21:48:16 · 481 阅读 · 0 评论 -
【旋转矩阵】Rotate Image
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?public class Solution { public void rotate(int[原创 2014-04-17 22:04:28 · 617 阅读 · 0 评论