leetcode双人赛-LeetCode:LeetCode上的算法解析

时间:2021-06-30 05:01:57
【文件属性】:
文件名称:leetcode双人赛-LeetCode:LeetCode上的算法解析
文件大小:64KB
文件格式:ZIP
更新时间:2021-06-30 05:01:57
系统开源 leetcode双人赛 给自己的目标:每日一题 在做题的过程中记录下解题的思路或者重要的代码碎片以便后来翻阅。题目从编号1开始逐渐递增。 1. Two Sum 题目:给出一个数组和一个目标值,求数组内两个值相加与目标值相等的下标。假设唯一解。 Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1]. 使用 HashMap 做存储,value为num值,key为目标值减去value后需要的值。 public class Solution { public int[] twoSum(int[] nums, int target) { int[] answer = new int[2]; HashMap hashMap = new HashMap<>(); for (int i=0;i<nums.length;i++){ if(hashMap.containsKey(nums[i])){ answer[0] = hashMap.
【文件预览】:
LeetCode-master
----src()
--------RemoveEndNode.java(920B)
--------SearchForARange.java(2KB)
--------NQueens.java(2KB)
--------CombinationSumII.java(2KB)
--------MinimumPathSum.java(856B)
--------PermutationsII.java(1KB)
--------TrappingRainWater.java(805B)
--------NQueens2.java(1KB)
--------MedianArrays.java(1KB)
--------ZigZag.java(892B)
--------PermutationSequence.java(730B)
--------SwapNodesinPairs.java(1KB)
--------AddBinary.java(929B)
--------LongestCommonPrefix.java(806B)
--------RomanToInteger.java(1KB)
--------LetterCombinationsOfPhoneNumber.java(1KB)
--------TwoSum.java(627B)
--------SubstringwithConcatenationofAllWords.java(2KB)
--------SudokuSolver.java(2KB)
--------TextJustification.java(2KB)
--------ContainerWithMostWater.java(656B)
--------PowXN.java(544B)
--------Sum3Closest.java(1KB)
--------LengthofLastWord.java(552B)
--------GenerateParentheses.java(862B)
--------RegularExpressionMatching2.java(1KB)
--------WildcardMatching.java(2KB)
--------RotateList.java(1KB)
--------FirstMissingPositive.java(980B)
--------Sum4.java(2KB)
--------IntegerToRoman.java(645B)
--------MergeIntervals.java(2KB)
--------DivideTwoIntegers.java(1KB)
--------PalindromeNumber.java(524B)
--------NextPermutation.java(1KB)
--------ValidSudoku.java(1KB)
--------SpiralMatrixII.java(2KB)
--------LongestValidParentheses.java(2KB)
--------ReverseInteger.java(631B)
--------MergekSortedLists.java(2KB)
--------ClimbingStairs.java(476B)
--------UniquePaths.java(695B)
--------SearchinRotatedSortedArray.java(431B)
--------UniquePathsII.java(1KB)
--------JumpGameII.java(561B)
--------ValidNumber.java(486B)
--------RotateImage.java(656B)
--------GroupAnagrams.java(980B)
--------CountAndSay.java(885B)
--------SqrtX.java(410B)
--------Atoi.java(1KB)
--------Permutations.java(1KB)
--------RemoveDuplicatesfromSortedArray.java(633B)
--------RemoveElement.java(559B)
--------AddTwoNumber.java(1KB)
--------MergeTwoSortedLists.java(1KB)
--------RegularExpressionMatching.java(2KB)
--------ReverseNodesInkGroup.java(2KB)
--------Implement_strStr.java(308B)
--------LongestSubstring.java(748B)
--------SpiralMatrix.java(2KB)
--------JumpGame.java(714B)
--------MultiplyStrings.java(2KB)
--------Sum3.java(1KB)
--------ValidParentheses.java(973B)
--------SearchInsertPosition.java(753B)
--------InsertInterval.java(3KB)
--------MaxSubArray.java(595B)
--------CombinationSum.java(1KB)
--------PalindromicSubstring.java(2KB)
--------PlusOne.java(803B)
----.gitignore(15B)
----README.md(88KB)

网友评论