05 2017 档案
摘要:题目: Given an array of integers, the majority number is the number that occurs more than half of the size of the array. Find it. Notice You may assume
阅读全文
摘要:calchist函数需要包含头文件 #include <opencv2/imgproc/imgproc.hpp> 函数声明(三个重载 calchist函数): 官方文档: The functions calcHist calculate the histogram of one or more ar
阅读全文
摘要:题目: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
阅读全文
摘要:实测,Ubuntu16.04,gcc 5.3.0&5.4.0(编译选项选择C++11和不选择新标准结果相同) 输出为 而同样的代码,在Windows下VS环境中, 输出为 这个就很奇怪了,只能取看具体操作情况了,下面是汇编文件,有空填坑(g++ -S ex.cpp生成汇编文件)
阅读全文
摘要:1. split() split()通过指定分隔符对字符串进行切片,如果参数num 有指定值,则仅分隔 num 个子字符串 split()方法语法:str.split(str="", num=string.count(str)).参数str -- 分隔符,默认为所有的空字符,包括空格、换行(\n)、
阅读全文
摘要:1.numpy.genfromtxt() numpy.genfromtxt() CSV文件很容易被numpy类库的genfromtxt方法解析 2.
阅读全文
摘要:1.Mat::imread() C++: Mat imread(const string& filename, int flags=1 ) filename – Name of file to be loaded. flags – Flags specifying the color type of
阅读全文
摘要:c++规定:一个函数的默认实参既可以在定义中,也可在声明中指定,但在一个文件(准确的说,是一个作用域)中只能为一个形参指定默认实参一次
阅读全文
摘要:摘自https://docs.scipy.org 1.The Basics 1.1 numpy 数组基础 NumPy’s array class is called ndarray. ndarray.ndim the number of axes (dimensions) of the array.
阅读全文
摘要:1.numpy库:argsort() argsort函数返回的是数组值从小到大的索引值(升序排列) 一维: 降序升序排列的另一种方法: 二维:axis = 0 按列排序;axis = 1, 按行排序 总结:np.argsort(x) 升序排列,np.argsort(-x)降序排列
阅读全文
摘要:环境:Ubuntu16.04 anaconda Python2.7 opencv2.4.13 安装opencv后 import cv2 遇到错误信息: No module named cv2 安装opencv时make的过程中会出现文件“cv2.so”,它是连接OpenCV和python的关键文件。
阅读全文
摘要:1. python脚本语言的第一行,目的就是指出,你想要你的这个文件中的代码用什么可执行程序去运行它 #!/usr/bin/python 是告诉操作系统执行这个脚本的时候,调用/usr/bin下的python解释器;相当于写死了python路径; #!/usr/bin/env python 这种用法
阅读全文
摘要:1.取整函数 ceil(x)返回不小于x的最小整数值。floor(x)返回不大于x的最大整数值。round(x)返回x的四舍五入整数值。
阅读全文
摘要:1.matlab 调试子程序 在主程序进入子程序前一句加断点,然后step in,可以进入子程序。 但是直接在子程序里设置断点,运行主程序是不能进入子程序的。
阅读全文
摘要:简单理解: 对于一块内存,浅拷贝只是增加了一个指针,这样两个变量都指向这块内存,二深拷贝则是先开辟一块同等大小的新内存区,将待拷贝内存的内容复制过来,再赋予一个指向新内存的指针。区别在于:浅拷贝会造成对新变量产生变动时有可能会操作该变量所指的内存中所存储的内容,那么浅拷贝时改变新指针所指内存值会造成
阅读全文
摘要:F1 查看帮助F2 跳转到函数定义(和Ctrl+鼠标左键一样的效果)Shift+F2 声明和定义之间切换F4 头文件和源文件之间切换Ctrl+1 欢迎模式Ctrl+2 编辑模式Ctrl+3 调试模式Ctrl+4 项目设置模式Ctrl+5 帮助模式 Ctrl+6 输出模式Alt+0 显示或者隐藏侧边条
阅读全文
摘要:题目: Given three strings: s1, s2, s3, determine whether s3 is formed by the interleaving of s1 and s2. Given three strings: s1, s2, s3, determine wheth
阅读全文
摘要:题目: Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed fr
阅读全文
摘要:题目: Given two strings, find the longest common subsequence (LCS). Your code should return the length of LCS. Given two strings, find the longest commo
阅读全文
摘要:题目: Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You h
阅读全文
摘要:题目: Given a sequence of integers, find the longest increasing subsequence (LIS). You code should return the length of the LIS. Given a sequence of int
阅读全文
摘要:函数签名的概念 函数签名主要包括1、函数名;2、参数列表(参数的个数、数据类型和顺序);但是注意,C++官方定义中函数签名不包括返回值!! 1、重载 函数重载是指在同一作用域内,可以有一组具有相同函数名,不同参数列表的函数,这组函数被称为重载函数,与函数返回类型无关。重载要求参数列表必须不同,比如参
阅读全文
摘要:题目: Count the number of k's between 0 and n. k can be 0 - 9. Count the number of k's between 0 and n. k can be 0 - 9. Count the number of k's between
阅读全文
摘要:此贴为汇总贴 673. Number of Longest Increasing Subsequence 075. Sort Colors 009. Palindrome Number 008. String to Integer (atoi) 007. Reverse Integer 006. Z
阅读全文
摘要:摘要: 1. 面向对象程序设计的核心思想是数据抽象、继承和动态绑定。数据抽象将类的接口和实现分离;继承定义相似的类型并对齐相似关系建模;动态绑定,在一定程度上忽略相似类型的区别,而以统一的方式使用它们的对象。 2. 派生类列表中每个基类前面可以有访问说明符;派生类必须在其内部对所有重新定义的虚函数进
阅读全文
摘要:题目: Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Example Given
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same re
阅读全文
摘要:题目: Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. Exampl
阅读全文
摘要:题目: 题解: Solution 1 () Solution 1.2 Solution 2 () Bit Manipulation This is the most clever solution that I have seen. The idea is that to give all the
阅读全文
摘要:题目: Given a list of numbers that may has duplicate numbers, return all possible subsets Notice Each element in a subset must be in non-descending orde
阅读全文
摘要:题目: Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions. Example For n=4, ther
阅读全文
摘要:题目: The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return
阅读全文
摘要:题目: The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return
阅读全文
摘要:题目: Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. How we serialize an undirected graph: Nodes are la
阅读全文
摘要:题目: Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the
阅读全文
摘要:题目: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. Example 2 1->2->3 => / \ 1 3 2 1->2-
阅读全文
摘要:题目: Given a sorted (increasing order) array, Convert it to create a binary tree with minimal height. Example Given [1,2,3,4,5,6,7], return 4 / \ 2 6 /
阅读全文
摘要:题目: A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep
阅读全文
摘要:题目: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example Given lists: [ 2->4->null, null, -1->nu
阅读全文
摘要:题目: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Example Given -21->10->4->5, tail connects to node
阅读全文
摘要:题目: Given a linked list, determine if it has a cycle in it. Example Given -21->10->4->5, tail connects to node index 1, return true Given -21->10->4->
阅读全文
摘要:题目: Given a singly linked list L: L0 → L1 → … → Ln-1 → Ln reorder it to: L0 → Ln → L1 → Ln-1 → L2 → Ln-2 → … Example Given 1->2->3->4->null, reorder i
阅读全文
摘要:题目: Sort a linked list in O(n log n) time using constant space complexity. Example Given 1->3->2->null, sort it to 1->2->3->null. Given 1->3->2->null,
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Reverse a linked list from position m to n. Given m, n satisfy the following condition: 1 ≤ m ≤ n ≤ length of list. Example Given 1->2->3->4->5->N
阅读全文
摘要:题目: Reverse a linked list. Example For linked list 1->2->3, the reversed linked list is 3->2->1 For linked list 1->2->3, the reversed linked list is 3
阅读全文
摘要:题目: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example Given 1->2
阅读全文
摘要:题目: Given a sorted linked list, delete all duplicates such that each element appear only once. Example Given 1->1->2, return 1->2.Given 1->1->2->3->3,
阅读全文
摘要:题目: Given a root of Binary Search Tree with unique value for each node. Remove the node with given value. If there is no such a node with given value
阅读全文
摘要:题目: Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Find all the keys of tree in range k1 to k2. i.e. print all
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). Example Given binary tree {3
阅读全文
摘要:题目: Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes. The lowest common ancestor is the node with
阅读全文
摘要:题目: Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. Example Given the below binary tree: 1 / \ 2 3
阅读全文
摘要:模板: 1.先序遍历三种方法 1)迭代: 2)递归: 3)分治: 模板2:DFS: 1) Traverse 2) Divide and Conquer 栈实现非递归DFS
阅读全文
摘要:题目: Suppose a sorted array 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). You are given a targe
阅读全文
摘要:题目: Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers s
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2] have the following uniqu
阅读全文
摘要:题目: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that
阅读全文
摘要:题目: 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
阅读全文
摘要:题目: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sort
阅读全文
摘要:题目: Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators
阅读全文
摘要:题目: Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between t
阅读全文
摘要:题目: Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the bal
阅读全文
摘要:题目: 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,-
阅读全文
摘要:题目: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at a
阅读全文
摘要:题目: Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty s
阅读全文
摘要:题目: 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 pa
阅读全文
摘要:题目: 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 yo
阅读全文
摘要:题目: Write an efficient algorithm that searches for a value in an m x n matrix, return the occurrence of it. This matrix has the following properties:
阅读全文
摘要:题目: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sort
阅读全文
摘要:题目: Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the tel
阅读全文
摘要:题目: Suppose a sorted array 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 elem
阅读全文
摘要:题目: There is an integer array which has the following features: The numbers in adjacent positions are different. A[0] < A[1] && A[A.length - 2] > A[A.
阅读全文
摘要:题目: The code base version is an integer start from 1 to n. One day, someone committed a bad version in the code case, so it caused this version and th
阅读全文
摘要:题目: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted i
阅读全文
摘要:模板:(通用模板,推荐) 给定一个排序的整数数组(升序)和一个要查找的整数target,用O(logn)的时间查找到target第一次出现的下标(从0开始),如果target不存在于数组中,返回-1。 若将条件改为查找target最后一次出现的下标(从0开始),那么程序将发生改变,循环中如果 arr
阅读全文
摘要:题目: A message containing letters from A-Z is being encoded to numbers using the following mapping: Given an encoded message containing digits, determi
阅读全文