Search in Rotated Sorted Array
其实不太能理解为什么这题能标成hard,因为用很直观的算法便可以解出来。由于数组是被翻转过的,所以被分成两个部分,每个部分又都是有序的。所以先判断先判断一下要查找的数是在前半段还是后半段,然后依次查找即可。
1 | public class Solution { |
Search in Rotated Sorted Array
其实不太能理解为什么这题能标成hard,因为用很直观的算法便可以解出来。由于数组是被翻转过的,所以被分成两个部分,每个部分又都是有序的。所以先判断先判断一下要查找的数是在前半段还是后半段,然后依次查找即可。
1 | public class Solution { |
原文作者: findingsea
原文链接: http://findingsea.github.io/2015/03/30/search-in-rotated-sorted-array/
发表日期: March 30th 2015, 10:34:00 am
版权声明: 本文采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可
jsonContent:
meta: false
pages: false
posts:
title: true
date: true
path: true
text: false
raw: false
content: false
slug: false
updated: false
comments: false
link: false
permalink: false
excerpt: false
categories: true
tags: true