ShannonHung / ShannonHung.github.io

2 stars 0 forks source link

LeetCode #1 Two Sum - 刷題之旅 | Shannon's Blog 🐟 技術 | 生活 | 旅行 #96

Open ShannonHung opened 3 months ago

ShannonHung commented 3 months ago

https://shannonhung.github.io/posts/leetcode-1-two-sum/

1 題目描述 2 解法 2.1 暴力解 簡單粗暴些,兩重循環,遍歷所有情況看相加是否等於目標和,如果符合直接輸出。 時間複雜度:O(n²) 空間複雜度:O(1) 12345678910111213public int[] twoSum(int[] nums, int target) { int []ans=new int[2]; for(int i=0;i<nums

leozzmc commented 3 months ago

太厲害了