国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

LeetCode-SearchinRotatedSortedArrayII

2019-11-14 14:54:03
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

題目:

Follow up for "Search in Rotated Sorted Array":
What if duplicates are allowed?

Would this affect the run-time complexity? How and why?

Write a function to determine if a given target is in the array.

 

思路:

直接循環(huán)一遍查找

package array;public class SearchInRotatedSortedArrayII {    public boolean search(int[] nums, int target) {        int len;        if (nums == null || (len = nums.length) == 0) return false;        for (int i = 0; i < len; ++i)             if (nums[i]==target)                return true;        return false;    }        public static void main(String[] args) {        // TODO Auto-generated method stub        int[] nums = { 3, 1, 1 };        SearchInRotatedSortedArrayII s = new SearchInRotatedSortedArrayII();        System.out.PRintln(s.search(nums, 3));    }}

 


發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 永胜县| 卫辉市| 合水县| 桃园市| 肥乡县| 涪陵区| 砀山县| 双桥区| 南投县| 苗栗县| 红河县| 丰宁| 饶平县| 深水埗区| 安溪县| 翁源县| 宁国市| 安达市| 威远县| 莆田市| 新巴尔虎左旗| 兴隆县| 博白县| 晋中市| 天门市| 鸡泽县| 铜山县| 华安县| 平泉县| 龙胜| 千阳县| 涿鹿县| 南宁市| 抚顺县| 郓城县| 阿尔山市| 东丽区| 文山县| 四会市| 商南县| 海淀区|