- 博客(28)
- 收藏
- 关注
转载 c/c++ static
总结一下:c:静态局部->初始化一次放在全局数据区,类似于全局但是可以属于函数本身(静态全局、静态函数)->隔离c++:静态成员函数 -> 不用初始化实力可以调用 但只能使用静态成员变量、静态成员变量->属于class所有对象共用一个C 语言的 static 关键字有三种(具体来说是两种)用途:1. 静态局部变量:用于函数体内部修饰变量,这种变量的生存期长于该函
2017-04-11 11:36:51
224
原创 leetcode 513
Given a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1 3Output:1Example 2: Input: 1 / \ 2 3 / /
2017-04-10 23:59:34
284
原创 leetcode 171
Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ...
2017-04-10 17:00:56
194
原创 leetcode 387 map根据value排序
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.Note:
2017-04-10 16:33:19
259
原创 leetcode122
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on
2017-04-10 15:48:05
178
转载 const 总结
1.const修饰的变量不能被修改,即只是可读const int 与 int const相同2.修饰指针时:int b=100;const int * a=&b [1];int const *a=&b; [2] int* const a=&b; [3] const int* const a =&b; [4]如果
2017-04-10 08:16:20
297
原创 leetcode 347 map根据value排序
Given a non-empty array of integers, return the k most frequent elements.For example,Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ number
2017-04-08 23:27:46
239
原创 leetcode 238
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O
2017-04-08 14:30:55
229
原创 leetcode 371
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return 3.Credits:Special thanks to @fujiaozhu for adding this prob
2017-04-07 18:45:05
178
原创 leetcode 104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Subscribe to see which compani
2017-04-06 21:28:59
161
原创 leetcode 344. Reverse String
Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".Subscribe to see which companies asked this question.判断size=
2017-04-06 13:47:59
135
原创 leetcode 412 to_string 转string atoi(str.c_str())转int
Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”.
2017-04-06 13:00:37
342
原创 leetcode 78!!!vector push_back不能和迭代器同时使用!!!
Given a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets.For example,If nums = [1,2,3], a solution is:[ [3], [1],
2017-04-06 11:03:50
1131
原创 leetcode 64
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at
2017-04-06 00:01:57
175
原创 leetcode 120
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], [
2017-04-05 22:52:22
190
原创 leetcode 91
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu
2017-04-04 00:06:34
333
原创 leetcode 413
A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequence:
2017-04-03 21:01:12
357
原创 leetcode 121
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),
2017-04-03 20:18:03
220
原创 leetcode 53
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [4,-1,2,1] ha
2017-04-03 14:22:54
253
原创 leetcode 303----sizeof指的是指针的大小而不是数组的大小!
先说坑!:[cpp] view plain copy #include using namespace std; void fun(int *P) { cout"在函数中"sizeof(P)} int main() { int A[10]; int* B=new int[
2017-04-03 13:27:26
338
原创 leetcode 70
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a posi
2017-04-03 12:31:02
191
原创 leetcode 377 memset!!!
Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.Example:nums = [1, 2, 3]target = 4The pos
2017-04-03 00:10:18
575
原创 leetcode 494
You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.Find out
2017-04-02 15:06:13
145
原创 leecode 357
357. Count Numbers with Unique DigitAdd to LisGiven a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x n.Example:Given n = 2, return 91. (The answer s
2017-04-02 01:24:03
183
原创 leetcode 338 ---- 判断整数是2的幂
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
2017-04-02 00:26:28
131
原创 leetcode 21
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Subscribe to see which companies asked this questio
2017-03-30 21:39:34
127
原创 leetcode 86
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of
2017-03-30 19:18:07
222
原创 leetcode 61
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.Subscribe to see which compan
2017-03-30 10:15:33
249
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人