- 博客(17)
- 资源 (6)
- 收藏
- 关注
原创 162. Find Peak Element
A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks, in
2017-09-13 12:44:36 321
原创 154. Find Minimum in Rotated Sorted Array II
Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose an array sorted in ascending order is rotated
2017-09-13 12:22:32 357 1
原创 153. Find Minimum in Rotated Sorted Array
Suppose an array sorted in ascending order 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).Find the minimum element.You may assume no
2017-09-13 11:24:18 386 1
原创 152. Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the larges
2017-09-13 11:08:19 383 1
原创 binary tree traver
1. preorder travelclass Solution {public: vector preorderTraversal(TreeNode* root) { vector result; stack myStack; TreeNode * temp = root; while(!myStack.empty()
2017-09-12 15:51:55 359 1
原创 139. Word Break
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may as
2017-09-11 21:16:19 331 1
原创 137. Single Number II
Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one.Note:Your algorithm should have a linear runtime complexity. Coul
2017-09-11 18:53:57 295 1
原创 135. Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on
2017-09-11 16:31:01 272 1
原创 134. Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to
2017-09-11 15:30:33 274 1
原创 131. 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","b"], [
2017-09-10 16:29:25 279 1
原创 刷题七
给定一个N位数,例如12345,从里面去掉k个数字,得到一个N-k位的数,例如去掉2,4,得到135,去掉1,5,得到234。设计算法,求出所有得到的N-k位数里面最小的那一个?class Solution{ bool myFunc(vector & array, int m, vector & result){ if(array.size() <= m)
2017-09-05 21:17:25 326
原创 刷题六
求最大连续子序列和#include #include #include "math.h"#include "limits.h"using namespace std;class Solution{ public: int myMax(vector & array){ if(array.size() == 0) return 0
2017-09-05 19:17:52 268
原创 刷题五
字符串A和字符串B。是否B包含了A所有的字符#include #include using namespace std;class Solution{ public: bool myCheck(string & str1, string & str2){ if(str1.length() == 0) return true; if(str
2017-09-05 16:59:02 269
原创 刷题四
两个有序链表的合并class Solution{ public: Node * myMerge(Node * list1, Node * list2){ if(list1 == null) return list2; if(list2 == null) return list1; Node * head = new Node();
2017-09-05 16:45:47 222
原创 刷题三
给出一串数字,判断是否为有效二叉查找树的后序遍历序列(及是否能够通过这串后序遍历序列构造出二叉查找树)#include #include using namespace std;class Solution{ public: bool myCheck(vector & array){ int length = array.size();
2017-09-05 16:13:52 247
原创 刷题二
实现带有重复元素的二分查找,如果查找的元素重复,返回重复元素的起始位置。#include #include using namespace std;class Solution{ public: int binarySearch(vector & array, int target){ if(array.size() == 0)
2017-09-05 15:37:12 244
原创 刷题
对于数组A[0,1,2,3,4,...,k],求得0#include #include #include "math.h"using namespace std;class Solution{ public: bool maxSum(vector & array, int & result){ if(array.size() <= 1)
2017-09-05 15:08:25 373
vassistx破解
2015-11-09
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人