/**
* @param {number[]} nums
* @return {number}
*/
var findPeakElement = function(nums) {
let len = nums.length;
if(len < 2) {
return 0;
}
for(let i = 0; i < len; ++i) {
if((nums[i] > nums[i - 1] || i === 0) && (nums[i] > nums[i + 1] || i === (len - 1))) {
return i;
}
}
};
複製程式碼
LeetCode 162 Javascript
相關文章
- LeetCode-162-尋找峰值LeetCode
- 162、黃鶴樓
- Nulls Indicate Absence of Value (162)Null
- 162. 尋找峰值
- Leetcode 921 JavascriptLeetCodeJavaScript
- Leetcode #463 JavascriptLeetCodeJavaScript
- Leetcode # 495 JavascriptLeetCodeJavaScript
- Leetcode 513 javascriptLeetCodeJavaScript
- LeetCode 747 JavaScriptLeetCodeJavaScript
- PostgreSQL DBA(162) - Extension(pg_catcheck)SQL
- Leetcode 229 JavaScriptLeetCodeJavaScript
- LeetCode 799 JavaScriptLeetCodeJavaScript
- LeetCode #378 JavaScriptLeetCodeJavaScript
- LeetCode 70題 爬樓梯 -- JavaScriptLeetCodeJavaScript
- LeetCode 存在重複元素之JavaScriptLeetCodeJavaScript
- Oracle 11G OCP 1Z0-052 162Oracle
- LeetCode7.整數反轉 JavaScriptLeetCodeJavaScript
- Leetcode 685. Redundant Connection II JavascriptLeetCodeJavaScript
- LeetCode刷題(javascript,python3)LeetCodeJavaScriptPython
- Leetcode之javascript解題(No33-34)LeetCodeJavaScript
- Educational Codeforces Round 162 (Rated for Div. 2) - VP記錄
- Leetcode 611 javascript Valid Triangle NumberLeetCodeJavaScript
- 每週一書:162頁《笨辦法學 Python》分享!Python
- 【手摸手玩轉 OceanBase 162】發起資料備份
- LeetCode 695. Max Area of Island javascript解決方案LeetCodeJavaScript
- 找到好工作之 LeetcodeTop100(Easy) by JavaScriptLeetCodeJavaScript
- 用 JavaScript 刷 LeetCode 的正確姿勢【進階】JavaScriptLeetCode
- Leetcode javascript 3 longest-substring-without-repeating-charactersLeetCodeJavaScript
- Leetcode 202 Happy Number Javascript 解決方案LeetCodeAPPJavaScript
- 科技愛好者週刊(第 162 期):生活就像《吃豆人》遊戲遊戲
- LeetCode 之 JavaScript 解答第一題 —— 兩數之和(Two Sum)LeetCodeJavaScript
- LeetCode 之 JavaScript 解答第169題 —— 求眾數 I(Majority Element)LeetCodeJavaScript
- LeetCode 之 JavaScript 解答第69題 —— X 的平方根(Squrt(x))LeetCodeJavaScript
- LeetCode 之 JavaScript 解答第20題 —— 有效的括號(Valid Parentheses)LeetCodeJavaScript
- LeetCode演算法簡單題--JavaScript(每天一道題)LeetCode演算法JavaScript
- PostgreSQL 原始碼解讀(162)- 查詢#82(如何構建表示式解析步驟#2)SQL原始碼
- (資料科學學習手札162)Python GIS神器geopandas 1.0版本釋出資料科學Python
- 【Leetcode 346/700】79. 單詞搜尋 【中等】【回溯深度搜尋JavaScript版】LeetCodeJavaScript