01 2018 档案
摘要:You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in Sis a type of stone
阅读全文
摘要:友元 类可以允许其他类或函数访问它的非共有成员,办法是令其他类或函数成为它的友元。如果类想把一个函数作为它的友元,只需要添加一条以friend关键字开始的函数声明语句即可。 友元声明只能出现在类定义的内部,但是在类内出现的具体位置不限,友元不是类的成员也不受它所在区域访问控制级别的约束。 一般来说最
阅读全文
摘要:构造函数 每个类都分别定义了它的对象被初始化的方式,类通过一个或几个特殊的成员函数来控制其对象的初始化过程,这些函数叫做构造函数。 构造函数的任务是初始化类对象的数据成员,无论何时只要类的对象被创建,就会执行构造函数。 构造函数的名字和类名相同。和其他函数不一样的是,构造函数没有返回类型;除此之外类
阅读全文
摘要:Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2] have the following unique pe
阅读全文
摘要:Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). Note: The solution set must not conta
阅读全文
摘要:Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. For ex
阅读全文
摘要: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 num
阅读全文
摘要:Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums
阅读全文
摘要:Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example,If n = 4 and k = 2, a solution is: [ [2,4], [3,4
阅读全文
摘要:Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N numbers successfully if one of t
阅读全文
摘要:A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now given an M x N matrix, return True if and only if the m
阅读全文
摘要: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
阅读全文
摘要:Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4. However, you can add any
阅读全文
摘要:You need to find the largest value in each row of a binary tree. Example: Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9] You need to find the largest
阅读全文
摘要:Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are c
阅读全文
摘要:Given a sorted array consisting of only integers where every element appears twice except for one element which appears once. Find this single element
阅读全文
摘要:Given a binary tree, find the leftmost value in the last row of the tree. Example 1: Example 2: Note: You may assume the tree (i.e., the given root no
阅读全文
摘要:Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twi
阅读全文
摘要:Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the pers
阅读全文
摘要: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 r
阅读全文
摘要:Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may ass
阅读全文
摘要:Given two strings representing two complex numbers. You need to return a string representing their multiplication. Note i2 = -1 according to the defin
阅读全文
摘要:A string S of lowercase letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one p
阅读全文
摘要:Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary representation
阅读全文
摘要:Given an integer array with no duplicates. A maximum tree building on this array is defined as follow: Construct the maximum tree by the given array a
阅读全文
摘要:Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements in A. We want to find
阅读全文
摘要:this指针 一个对象的this指针并不是对象本身的一部分,不会影响sizeof(对象)的结果。 this指针的作用域是在类内部,当在类的非静态成员函数中访问类的非静态成员函数的时候,编译器会自动将对象本身的地址作为一个隐含参数传递给函数。 举个栗子 插一句:定义在类内部的函数是隐式的inline函
阅读全文
摘要:Find the largest palindrome made from the product of two n-digit numbers. Since the result could be very large, you should return the largest palindro
阅读全文
摘要:Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers. You may
阅读全文
摘要:You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c
阅读全文
摘要:Description: Count the number of prime numbers less than a non-negative number, n. 使用sieve of Eratosthenes方法对质数进行筛选。 题目要求就是写出这个算法。 原理是:给出要筛数值的范围n,找出出以
阅读全文
摘要:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: Pan
阅读全文
摘要:Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexi
阅读全文
摘要:函数指针 函数指针指向的是函数而非对象,和其他指针一样,函数指针指向某种特定类型。 函数的类型由它的返回值类型和形参类型共同决定,与函数名无关。 pf指向一个函数,该函数的参数是两个const string的引用,返回值是bool类型,*pf两边的括号必不可少 使用函数指针 当我们把函数名作为一个值
阅读全文
摘要:Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an inte
阅读全文
摘要:You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated into N+1 groups b
阅读全文
摘要:In a given integer array nums, there is always exactly one largest element. Find whether the largest element in the array is at least twice as much as
阅读全文
摘要:三种函数相关的语言特性:默认实参、内联函数、constexpr函数 默认实参 某些函数有这样一些形参,在函数的很多次调用中它们都被赋予一个相同的值,此时,我们把这个反复出现的值称为函数的默认实参。调用含有默认实参的函数时,可以包含该实参,也可以忽略该实参。 其中我们为每个形参都提供了默认实参,默认实
阅读全文

浙公网安备 33010602011771号