- 博客(125)
- 收藏
- 关注
转载 454. 4Sum II 解题记录
题目描述:Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make problem a bit easier, all A, B, C, D hav...
2018-11-10 21:16:00
131
转载 程序设计实习 作业3 魔兽世界终极版
Description:魔兽世界的西面是红魔军的司令部,东面是蓝魔军的司令部。两个司令部之间是依次排列的若干城市,城市从西向东依次编号为1,2,3 .... N ( N <= 20 )。红魔军的司令部算作编号为0的城市,蓝魔军的司令部算作编号为N+1的城市。司令部有生命元,用于制造武士。两军的司令部都会制造武士。武士一共有 dragon 、ninja、iceman、lion...
2018-08-21 19:47:00
567
转载 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 nod...
2018-04-18 23:06:00
128
转载 93. 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"]....
2018-04-17 16:30:00
105
转载 96. Unique Binary Search Trees 解题记录
题目描述:Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's.1 1 3 3 2...
2018-04-16 09:14:00
85
转载 95. Unique Binary Search Trees II 解题记录
题目描述:Given an integer 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 b...
2018-04-15 09:37:00
112
转载 71. Simplify Path 解题记录
题目描述:Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"Corner Cases:Did you consider the ca...
2018-04-14 22:33:00
100
转载 260. Single Number III 解题记录
题目描述:Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:...
2018-04-13 19:53:00
73
转载 300. Longest Increasing Subsequence 解题记录
题目描述:Given an unsorted array of integers, find the length of longest increasing subsequence. For example,Given [10, 9, 2, 5, 3, 7, 101, 18],The longest increasing subsequence is [2, 3, 7,...
2018-04-12 23:33:00
73
转载 238. Product of Array Except Self 解题记录
题目描述: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...
2018-04-11 19:04:00
70
转载 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 t...
2018-04-10 21:46:00
96
转载 216. Combination Sum III 解题记录
题目描述:Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.Example 1:...
2018-04-08 23:42:00
82
转载 215. Kth Largest Element in an Array 解题记录
题目描述:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example, Given [3,2,1,5,6,4] and k = 2, r...
2018-04-07 22:49:00
83
转载 209. Minimum Size Subarray Sum 解题记录
题目描述:Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead.For example, g...
2018-04-06 12:09:00
127
转载 201. Bitwise AND of Numbers Range 解题记录
题目描述:Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.For example, given the range [5, 7], you should return 4.解...
2018-04-05 12:22:00
116
转载 179. Largest Number 解题记录
题目描述:Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result m...
2018-04-04 21:32:00
114
转载 多态和虚函数
虚函数概念:在类的定义中,前面有virtual关键字的成员函数就是虚函数。virtual关键字只用在类定义里的函数声明中,写函数体时不用。构造函数和静态成员函数不能是虚函数。多态的表现形式:1)派生类的指针可以赋给基类指针。 通过基类指针可以调用基类和派生类中的同名虚函数时:指针指向哪个类的对象,就调用哪个类的虚函数。2) 派生类的对象可以赋给基类...
2018-04-03 21:43:00
111
转载 200. Number of Islands 解题记录
题目描述:Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. Yo...
2018-04-03 15:36:00
110
转载 199. Binary Tree Right Side View 解题记录
题目描述:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example: Given the following binary tree...
2018-04-02 08:39:00
79
转载 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 pe...
2018-04-01 18:29:00
77
转载 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 as...
2018-04-01 00:25:00
107
转载 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.解题思路:这题还是用136也就是上一题的思路,异或两次就会变为0,这次的数组中的重复元素变为3个,所以要跳过一个不...
2018-03-30 23:38:00
472
转载 130. Surrounded Regions 解题记录
题目描述:Given a 2D board containing 'X' and 'O' (the letter 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,...
2018-03-29 11:13:00
111
转载 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 number 123.Find the...
2018-03-28 17:09:00
67
转载 复合关系和继承关系
继承关系:“是”的关系B是基类A的一个派生类逻辑上要求:“一个B对象也是一个A对象”。例:“男人”是一个“人”,“女人”也是一个“人”,因此“男人”和“女人”就可以从“人”中继承得到,但男人和女人不能互相继承。复合关系:“有”关系类C中“有”成员变量k,k是类D的对象,则C和D是复合关系一般逻辑上要求:“D对象是C对象的固有属性或组成部...
2018-03-27 19:56:00
961
转载 继承与派生
概念:继承:在定义一个新的类B时,如果该类与某个已有的类A相似(指的是B拥有A的全部特点),那么就可以把A作为一个基类,而把B作为基类的一个派生类(也称子类)派生类可以对基类进行扩充(成员函数和成员变量)派生类一经定义后,可以独立使用,不依赖于基类。派生类拥有基类的全部成员函数和成员变量,无论时private、protected、public。但在派生类中的各个成...
2018-03-27 19:29:00
82
转载 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], ...
2018-03-26 09:10:00
113
转载 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 ...
2018-03-25 23:26:00
87
转载 102. 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,null,null,15,7], 3 ...
2018-03-24 22:11:00
70
转载 94. Binary Tree Inorder Traversal 解题记录
题目描述:Given a binary tree, return the inorder traversal of its nodes' values.For example: Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].Note: Recursiv...
2018-03-23 22:23:00
51
转载 90. Subsets II 解题记录
题目描述:Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.For example, I...
2018-03-22 11:42:00
72
转载 89. Gray Code 解题记录
题目描述:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the se...
2018-03-21 19:23:00
75
转载 运算符重载
基本概念:对已有的运算符赋予多重的含义使同一运算符作用于不同类型的数据时,有不同类型的行为目的是扩展C++中提供的运算符的适用范围,以用于类所表示的抽象数据类型运算符重载的实质是函数重载:返回值类型 operator 运算符(形参表) { }可重载为普通函数和成员函数,成员函数的形参中因为this指针的关系,少了一个参数,其他都相同。赋值运算符'='重...
2018-03-20 17:54:00
81
转载 86. Partition List 解题记录
题目描述: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 ...
2018-03-20 17:14:00
96
转载 82. Remove Duplicates from Sorted List II 解题记录
题目描述:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example, Given 1->2->3->3->4->4->5, r...
2018-03-19 18:01:00
56
转载 81. Search in Rotated Sorted Array II 解题记录
题目描述: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).Write a function to determine if a given ...
2018-03-18 22:15:00
59
转载 80. Remove Duplicates from Sorted Array II 解题记录
题目描述:Follow up for "Remove Duplicates": What if duplicates are allowed at most twice?For example, Given sorted array nums = [1,1,1,2,2,3], Your function should return length = 5, with the f...
2018-03-17 13:27:00
78
转载 79. Word Search 解题记录
题目描述:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or ...
2018-03-16 20:10:00
96
转载 78. Subsets 解题记录
题目描述:Given a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.For example, If nums = [1,2,3], a solution...
2018-03-15 18:21:00
57
转载 常量对象、常量成员函数和常引用
常量对象:如果不希望某个对象的值被改变,则定义该对象的时候可以在前面加const关键字。常量对象只能调用类中的常量成员函数。const 类名 对象名;常量成员函数:如果不希望类中的某个函数修改类中的值,则定义该成员函数的时候可以在后面加const关键字。常量成员函数不能修改本类的成员变量(静态成员变量除外),也不能调用同类的非常量成员函数(静态成员函数除外)。类型...
2018-03-15 14:24:00
136
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人