![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
编程基础-查找
小郭不背锅
这个作者很懒,什么都没留下…
展开
-
search-insert-position
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 in order.You may assume no duplicates in the array....原创 2018-03-19 14:29:33 · 127 阅读 · 0 评论 -
公共字串计算
题目描述题目标题:计算两个字符串的最大公共字串的长度,字符不区分大小写详细描述:接口说明原型:int getCommonStrLength(char * pFirstStr, char * pSecondStr);输入参数: char * pFirstStr //第一个字符串 char * pSecondStr//第二个字符串 输入描述:输...原创 2018-03-28 09:49:25 · 169 阅读 · 0 评论 -
set-matrix-zeroes
题目描述Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight forward solution using O(m ...原创 2018-03-27 16:38:47 · 159 阅读 · 0 评论 -
container-with-most-water
Given n non-negative integers a1 , a2 , ..., an , where each represents a point at coordinate (i, ai ). n vertical lines are drawn such that the two endpoints of line i is at (i, ai ) and (i, 0). Find...原创 2018-03-22 11:45:28 · 138 阅读 · 0 评论 -
generate-parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()()"心...原创 2018-03-22 11:34:32 · 190 阅读 · 0 评论 -
n皇后问题
本来想直接套用八皇后的代码,修改后发现n>=10后num=0,找不到问题点,如果大家能发现什么问题麻烦告诉我:错误代码如下:public class Solution { int num = 0; public int totalNQueens(int n) { int[] isused = new int[n]; //每个位置是否被走过,是就是1,否就是0 int[] ar...原创 2018-03-26 10:32:11 · 108 阅读 · 0 评论 -
八皇后问题
会下国际象棋的人都很清楚:皇后可以在横、竖、斜线上不限步数地吃掉其他棋子。如何将 8 个皇后放在棋盘上(有8×8个方格),使它们谁也不能被吃掉!这就是著名的八皇后问题。对于某个满足要求的8皇后的摆放方法,定义一个皇后串a与之对应,即 a=b1b2...b8, 其中bi(1≤bi≤8)为相应摆法中第 i 行皇后所处的列数。已经知道8皇后问题一共有92组解(即92个不同的皇后串)。给出一个数n,要求...原创 2018-03-21 09:45:41 · 250 阅读 · 0 评论 -
百钱买鸡问题
题目描述公元前五世纪,我国古代数学家张丘建在《算经》一书中提出了“百鸡问题”:鸡翁一值钱五,鸡母一值钱三,鸡雏三值钱一。百钱买百鸡,问鸡翁、鸡母、鸡雏各几何?详细描述:接口说明原型:int GetResult(vector &list)输入参数: 无输出参数(指针指向的内存区域保证有效): list 鸡翁、鸡母、鸡雏组合的列表返回...原创 2018-03-20 13:54:47 · 488 阅读 · 0 评论 -
矩阵元素查找
题目描述有一个NxM的整数矩阵,矩阵的行和列都是从小到大有序的。请设计一个高效的查找算法,查找矩阵中元素x的位置。给定一个int有序矩阵mat,同时给定矩阵的大小n和m以及需要查找的元素x,请返回一个二元数组,代表该元素的行号和列号(均从零开始)。保证元素互异。测试样例:[[1,2,3],[4,5,6]],2,3,6返回:[1,2]这道题leetcode上也有类似的,有很多优化的解法...原创 2018-03-23 10:05:32 · 857 阅读 · 0 评论 -
search-a-2d-matrix
题目描述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 sorted from left to right.The first integer of ea...原创 2018-03-23 09:22:10 · 78 阅读 · 0 评论 -
path-sum
题目描述Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and...原创 2018-03-28 10:43:26 · 101 阅读 · 0 评论