
面试题
文章平均质量分 71
happyxuma1991
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
蛇形矩阵C++
输出以上螺旋矩阵#include #include using namespace std;// 输出螺旋矩阵void Matrix(){ const int size = 10; // 矩阵大小 int matrix[size][size] = { 0 }; int row = 0; int col = 0; int start = 1; // 起始值 int原创 2016-04-05 21:43:20 · 4436 阅读 · 0 评论 -
leetcode——116—— Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node. If t原创 2016-05-01 14:11:47 · 214 阅读 · 0 评论 -
leetcode——117——Populating Next Right Pointers in Each Node II
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 ext原创 2016-05-01 14:58:29 · 260 阅读 · 0 评论 -
leetcode——120——Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [6,原创 2016-05-01 15:14:48 · 260 阅读 · 0 评论 -
leetcode——129——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 number123.Find the total sum原创 2016-05-01 18:42:50 · 294 阅读 · 0 评论 -
leetcode——130——Surrounded Regions
Given a 2D board containing 'X' and 'O', capture all regions surrounded by'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X XX O O XX X原创 2016-04-21 14:20:45 · 339 阅读 · 0 评论 -
leetcode——338——Counting Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5原创 2016-04-21 19:01:43 · 282 阅读 · 0 评论 -
leetcode——238——Product of Array Except Self
Given an array of n integers where n > 1, nums, return an arrayoutput such that output[i] is equal to the product of all the elements ofnums except nums[i].Solve it without division and in O(n).原创 2016-04-22 10:49:52 · 219 阅读 · 0 评论 -
leetcode——341——Flatten Nested List Iterator
Given a nested list of integers, implement an iterator to flatten it.Each element is either an integer, or a list -- whose elements may also be integers or other lists.Example 1:Given the list [原创 2016-04-22 11:53:38 · 321 阅读 · 0 评论 -
leetcode——344——Reverse String
Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh". class Solution {public: string reverseString(string s) {原创 2016-04-22 13:49:47 · 378 阅读 · 0 评论 -
leetcode——114—— Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like:1 \ 2 \原创 2016-05-01 11:57:04 · 201 阅读 · 0 评论 -
leetcode——92——Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note:Given m, n satisfy the fol原创 2016-04-30 17:41:48 · 197 阅读 · 0 评论 -
leetcode——188——Best Time to Buy and Sell Stock IV
Say you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at most k transactions.Note:You may not原创 2016-04-30 17:23:42 · 288 阅读 · 0 评论 -
leetcode——113——Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example:Given the below binary tree and sum = 22, 5 / \原创 2016-04-27 17:50:04 · 233 阅读 · 0 评论 -
leetcode——98——Validate Binary Search Tree
Given 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 keys less than the node's key.The原创 2016-04-27 18:28:11 · 199 阅读 · 0 评论 -
leetcode——173——Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next() and原创 2016-04-27 18:52:04 · 291 阅读 · 0 评论 -
leetcode——95——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原创 2016-04-29 14:57:01 · 235 阅读 · 0 评论 -
leetcode——284——Peeking Iterator
Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek() operation -- it essentially peek() at the element that will be re原创 2016-04-30 11:43:17 · 246 阅读 · 0 评论 -
leetcode——309——Best Time to Buy and Sell Stock with Cooldown
Say you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one原创 2016-04-30 12:40:22 · 241 阅读 · 0 评论 -
leetcode——121——Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),原创 2016-04-30 15:53:28 · 190 阅读 · 0 评论 -
leetcode——122——Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one原创 2016-04-30 15:58:04 · 209 阅读 · 0 评论 -
leetcode——123——Best Time to Buy and Sell Stock III
Say you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at most two transactions.题意:用一个数组表示股票原创 2016-04-30 16:41:14 · 228 阅读 · 0 评论 -
求一个字符串中连续出现次数最多的子串
#include #include using namespace std;void main(){ string str = "abcabcabcccccdefefefefefef"; int len = str.length(); int maxCount = 0; string longest = ""; for(int pos1 = 0;原创 2016-06-02 14:51:46 · 209 阅读 · 0 评论