Leetcode:search_insert_position
一、 题目
给定一个数组和要插入数的大小。求插入的位置。
二、 分析
太水,直接扫描。过…….
class Solution {
public:
    int searchInsert(int A[], int n, int target) {
        for(int i=0;i<n;i++) {
        	if(target<=A[i]) {
        		return i;
        	}
        }
        return n;
    }
};
Leetcode:search_insert_position的更多相关文章
- 我为什么要写LeetCode的博客?
		
# 增强学习成果 有一个研究成果,在学习中传授他人知识和讨论是最高效的做法,而看书则是最低效的做法(具体研究成果没找到地址).我写LeetCode博客主要目的是增强学习成果.当然,我也想出名,然而不知 ...
 - LeetCode All in One 题目讲解汇总(持续更新中...)
		
终于将LeetCode的免费题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 477 Total Hamming Distance ...
 - [LeetCode] Longest Substring with At Least K Repeating Characters 至少有K个重复字符的最长子字符串
		
Find the length of the longest substring T of a given string (consists of lowercase letters only) su ...
 - Leetcode 笔记 113 - Path Sum II
		
题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...
 - Leetcode 笔记 112 - Path Sum
		
题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...
 - Leetcode 笔记 110 - Balanced Binary Tree
		
题目链接:Balanced Binary Tree | LeetCode OJ Given a binary tree, determine if it is height-balanced. For ...
 - Leetcode 笔记 100 - Same Tree
		
题目链接:Same Tree | LeetCode OJ Given two binary trees, write a function to check if they are equal or ...
 - Leetcode 笔记 99 - Recover Binary Search Tree
		
题目链接:Recover Binary Search Tree | LeetCode OJ Two elements of a binary search tree (BST) are swapped ...
 - Leetcode 笔记 98 - Validate Binary Search Tree
		
题目链接:Validate Binary Search Tree | LeetCode OJ Given a binary tree, determine if it is a valid binar ...
 
随机推荐
- Ioc 之 Unity的依赖注入
			
Unity是微软官方提供的一个Ioc容器,用来实现依赖注入,减少代码之间的耦合程度.使用Unity实现Ioc方式有两种,一种是使用代码方式实现,一种是利用配置文件来实现. 我们先来看一下代码方式是如何 ...
 - integer to roman  leetcode  c++实现
			
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...
 - myBatis的binding错误:Invalid bound statement (not found)
			
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误这个问题我找了好久,终于找到了正确的写 ...
 - js hover 下拉框
			
<div class="box"> <div class="a f">111111</div> <div class= ...
 - JS实现两版本号大小比较
			
JavaScript实现版本号比对(含字母) 昨天,有一道面试题,要求是这样的: 用你熟悉的编程语言,实现一个比较任意两个软件版本号大小的函数,如1.2.3a与1.2.4b进行比较,后者版本号更大,要 ...
 - C字符串指针遇到的问题
			
看下面的示例代码: int main() { char *ptr = "GeeksQuiz"; printf("%c\n", *&*&*ptr) ...
 - DNS域名系统
			
1. 什么是DNS? DNS是域名系统的缩写,DNS通过将域名与实际的Web服务器连接来帮助引导Internet上的流量.从本质上讲,它需要一个人性化的请求 – 像simcf.cc这样的域名 – 并将 ...
 - Ubuntu16.04下安装pip
			
按照下面的步骤来安装 sudo apt-get install python-setuptools python-dev build-essential 安装python2的pip (要想好你用p ...
 - PHP基于phpqrcode类生成二维码的方法详解
			
前期准备: 1.phpqrcode类文件下载,下载地址:https://sourceforge.net/projects/phpqrcode/2.PHP环境必须开启支持GD2扩展库支持(一般情况下都是 ...
 - (3) openssl genrsa(生成rsa私钥)
			
genrsa用于生成RSA私钥,不会生成公钥,因为公钥提取自私钥,如果需要查看公钥或生成公钥,可以使用openssl rsa命令. 使用man genrsa查询其用法. openssl genrsa ...