国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 襄汾县| 绵竹市| 灵璧县| 剑河县| 漳州市| 宜州市| 饶阳县| 兴山县| 寿宁县| 高清| 临桂县| 全南县| 贵德县| 应城市| 都江堰市| 阿坝县| 忻州市| 游戏| 安新县| 南澳县| 公主岭市| 华安县| 静乐县| 景宁| 定兴县| 册亨县| 内江市| 汉寿县| 黑河市| 巴楚县| 汉源县| 奈曼旗| 上栗县| 青河县| 南郑县| 芮城县| 灵寿县| 六安市| 陵川县| 裕民县| 尉氏县|