上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 37 下一页
摘要: Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be 阅读全文
posted @ 2017-12-08 12:11 immjc 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 选择排序的概念 选择排序(Selection sort)是一种简单直观的排序算法。它的工作原理如下。首先在未排序序列中找到最小(大)元素,存放到排序序列的起始位置,然后,再从剩余未排序元素中继续寻找最小(大)元素,然后放到已排序序列的末尾。以此类推,直到所有元素均排序完毕。 选择排序的主要特点与数据 阅读全文
posted @ 2017-12-08 11:51 immjc 阅读(191) 评论(0) 推荐(0) 编辑
摘要: Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), retur 阅读全文
posted @ 2017-12-07 12:10 immjc 阅读(84) 评论(0) 推荐(0) 编辑
摘要: Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses. Now, you are given p 阅读全文
posted @ 2017-12-07 11:54 immjc 阅读(191) 评论(0) 推荐(0) 编辑
摘要: Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Remov 阅读全文
posted @ 2017-12-06 20:29 immjc 阅读(128) 评论(0) 推荐(0) 编辑
摘要: Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note:n is positive and will fit within the range of a 32-bi 阅读全文
posted @ 2017-12-06 18:31 immjc 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 首先需要明确一个概念,就是*p++与(*p)++的区别。 *p++:对p取值,然后对p指针增加。 (*p)++:对p取值,然后对值增加。 ++a:表示取a的地址,对a的值进行增加,然后把这个值放入寄存器。结果可以作为左值。 实现代码如下: a++:表示取a的地址,把这个值放入寄存器,然后对内存中的a 阅读全文
posted @ 2017-12-06 10:41 immjc 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 给定一个包含 n 个整数的排序数组,找出给定目标值 target 的起始和结束位置。 如果目标值不在数组中,则返回[-1, -1] 样例 给出[5, 7, 7, 8, 8, 10]和目标值target=8, 返回[3, 4] 通过找出target的左边界(详解见[LintCode] First Po 阅读全文
posted @ 2017-12-05 20:05 immjc 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 给定一个排序的整数数组(升序)和一个要查找的整数target,用O(logn)的时间查找到target第一次出现的下标(从0开始),如果target不存在于数组中,返回-1。 样例 在数组 [1, 2, 3, 3, 4, 5, 10] 中二分查找3,返回2。 根据二分搜索的定义,找出这个target 阅读全文
posted @ 2017-12-05 17:21 immjc 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 二分搜索定义 二分搜索算法是一种在有序数组中查找某一特定元素的搜索算法。搜索过程中从数组的中间元素开始,如果中间元素正好是要查找的元素,则搜索过程结束;如果某一特定元素大于或小于中间元素,则在数组大于或小于中间元素的那一半中查找,而且跟开始一样从中间元素开始比较,如果在某一步骤数组为空,则代表找不到 阅读全文
posted @ 2017-12-05 12:17 immjc 阅读(217) 评论(0) 推荐(0) 编辑
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 37 下一页