
leetcode刷题
yvhqbat
whuster
展开
-
剑指offer之数据结构
#ifndef _LD_ARRAY_H_ #define _LD_ARRAY_H_#include <stack> #include <queue>using namespace std;//剑指offer,面试题3,P38,二维数组中的查找 bool Find(int *matrix, int rows, int columns, int number){ bool found = fal原创 2016-03-01 15:22:11 · 398 阅读 · 0 评论 -
Remove Duplicates from Sorted Array
描述 Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place wit原创 2016-02-26 09:06:30 · 291 阅读 · 0 评论 -
二分查找
//二分查找,binary search //给定一个整数X和整数A0,A1,A2...AN-1,后者已排序(从小到大),求使得Ai=X的下标i, //如果X不在数据中,则返回-1. //时间复杂度O(logN),空间复杂度O(1) int BinarySearch(int nums[], int n, int x){ int first, last, mid; first = 0;原创 2016-02-26 10:57:58 · 262 阅读 · 0 评论