- 博客(199)
- 资源 (5)
- 收藏
- 关注
原创 leetcode 刷题之路 27 Insertion Sort List
Sort a linked list using insertion sort.
2014-07-28 23:06:26 456
原创 leetcode 刷题之路 26 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-07-28 22:06:58 549
原创 leetcode 刷题之路 25 Sqrt(x)
d class Solution {public: int sqrt(int x) { int begin = 1, end = x, mid; while (begin < end) { mid == (begin + end) / 2; unsigned long long temp = mid*mid; if (temp == x) retu
2014-07-28 21:23:39 564
原创 leetcode 刷题之路 24 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-07-28 16:25:26 489
原创 leetcode 刷题之路 23 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-07-28 16:11:06 586
原创 leetcode 刷题之路 22 Anagrams
Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.给出一组字符串,要求返回是
2014-07-28 10:41:28 600
原创 leetcode 刷题之路 21 Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not found
2014-07-28 08:08:02 509
原创 leetcode 刷题之路 20 Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Note: Recursive solutio
2014-07-27 22:57:20 418
原创 leetcode 刷题之路 19 Valid Palindrome
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
2014-07-27 22:30:56 410
原创 leetcode 刷题之路 18 Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is pretty straight forward. Could you devis
2014-07-27 21:06:02 446
原创 leetcode 刷题之路 17 Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to
2014-07-26 23:05:11 476
原创 leetcode 刷题之路 16 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.
2014-07-26 19:55:50 465
原创 leetcode 刷题之路 15 Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is
2014-07-26 19:16:44 389
原创 leetcode 刷题之路 14 Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
2014-07-26 19:05:47 386
原创 leetcode 刷题之路 13 Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.链表的zuoxuan
2014-07-26 18:33:43 516
原创 leetcode 刷题之路 12 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].
2014-07-26 17:24:18 465
原创 leetcode 刷题之路 11 Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is
2014-07-26 15:42:55 533
原创 leetcode 刷题之路 10 Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
2014-07-24 12:36:10 460
原创 leetcode 刷题之路 9 Sum Root to Leaf Numbers
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 tota
2014-07-24 11:09:56 413
原创 leetcode 刷题之路 8 Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.
2014-07-24 10:20:44 391
原创 leetcode 刷题之路 7 Two Sum
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-07-23 23:38:21 527
原创 leetcode 刷题之路 6 Longest Consecutive Sequence
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
2014-07-22 13:48:56 433
原创 leetcode 刷题之路 5 Binary Tree Level Order Traversal 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},
2014-07-22 11:58:36 409
原创 leetcode 刷题之路 4 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-07-22 11:45:36 510
原创 leetcode 刷题之路 3 Max Points on a Line
Max Points on a Lineclass Solution {public: int maxPoints(vector &points) { if (points.empty()) return 0; int max = 0; int verticalNum = 0; int sameNum = 0; //记录重
2014-07-20 12:44:35 554
原创 leetcode 刷题之路 2 Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1",
2014-07-20 11:20:27 488
原创 第八十四题 (百度面试题)
第4组百度面试题 2010 年3 道百度面试题[相信,你懂其中的含金量] 1)a~z 包括大小写与0~9 组成的N 个数, 用最快的方式把其中重复的元素挑出来。
2014-07-19 00:32:25 572
原创 prim算法
// ConsoleApplication3.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#includeusing namespace std;const int MAX = 7;int edge[MAX][MAX];void prim();void test(){ for (int i = 0; i < MAX; i++) fo
2014-07-18 11:53:13 934 1
原创 华为机试整理
27.统计数字出现的次数,最大次数的统计出来举例:输入:323324423343输出:3,6#include "stdafx.h" #include #includeusing namespace std; /*27.统计数字出现的次数,最大次数的统计出来举例:输入:323324423343输出:3,6*/int main(int argc, _TC
2014-07-14 15:52:38 1356
原创 华为机试整理2
等方式#include "stdafx.h"#include#includeusing namespace std;int main(int argc, _TCHAR* argv[]){ //求两个长长整型的数据的和并输出 string s1,s2; string s3; getline(cin,s1); getline(cin,s2); int len1=s1.l
2014-07-12 23:47:26 656
原创 第十三题(输出该链表中倒数第k 个结点)
第13 题:题目:输入一个单向链表,输出该链表中倒数第k 个结点。链表的倒数第0 个结点为链表的尾指针。链表结点定义如下:struct ListNode{int m_nKey;ListNode* m_pNext;};
2014-07-12 18:02:51 549
原创 第12 题(特殊方法求1+2+…+n)
第12 题题目:求1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case 等关键字以及条件判断语句(A?B:C)。
2014-07-12 17:54:40 599
原创 第二题(设计包含min 函数的栈)
2.设计包含min 函数的栈。定义栈的数据结构,要求添加一个min 函数,能够得到栈的最小元素。要求函数min、push 以及pop 的时间复杂度都是O(1)。
2014-07-12 17:14:53 591
原创 第六题(下排每个数都是先前上排那十个数在下排出现的次数)
腾讯面试题:给你10 分钟时间,根据上排给出十个数,在其下排填出对应的十个数要求下排每个数都是先前上排那十个数在下排出现的次数。上排的十个数如下:【0,1,2,3,4,5,6,7,8,9】举一个例子,数值: 0,1,2,3,4,5,6,7,8,9分配: 6,2,1,0,0,0,1,0,0,00 在下排出现了6 次,1 在下排出现了2 次,2 在下排出现了1 次,
2014-07-12 16:27:05 1046
原创 第五题(查找最小的k 个元素)
5.查找最小的k 个元素题目:输入n 个整数,输出其中最小的k 个。例如输入1,2,3,4,5,6,7 和8 这8 个数字,则最小的4 个数字为1,2,3 和4。思路:选择排序,fuz
2014-07-12 16:11:55 1042
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人