LeetCode
kian240802
I will find my way
展开
-
Leetcode数组专题(Medium): 18.4Sum
Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: The solution set must not contain duplicate .原创 2020-07-06 15:37:50 · 93 阅读 · 0 评论 -
Leetcode数组专题(Medium): 15.3Sum
“独立思考” Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not contain duplicate triplets. Example: Given array nums原创 2020-06-27 16:16:21 · 90 阅读 · 0 评论 -
Leetcode数组专题(medium):11.Container With Most Water
“I’m so small…” Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms原创 2020-06-25 10:50:32 · 89 阅读 · 0 评论 -
LeetCode数组专题: 268.Missing Number
“为什么你没有经常来!” class Solution { public int missingNumber(int[] nums) { int n = nums.length; int totalSum = n*(n+1)/2; int res = 0; for(int num : nums){ res = totalSum - num; } return res; }原创 2020-06-24 22:22:31 · 96 阅读 · 0 评论 -
LeetCode数组专题: 217. Contains Duplicate && 219. Contains Duplicate II
“来啦来啦!!!” 217.Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. Example 1:I原创 2020-06-17 23:24:48 · 129 阅读 · 0 评论 -
LeetCode数组专题: 189. Rotate Array
"加油!相信自己” 189. Rotate Array Given an array, rotate the array to the right by k steps, where k is non-negative. Follow up: Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem. Could you do it in-place with原创 2020-06-17 21:52:00 · 102 阅读 · 0 评论 -
LeetCode算法专题一:数组(3)
“昨晚一晚没有睡,还不是因为做什么有意义的事情!希望最近调整过来!” 121Best Time to buy and sell stock Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share原创 2020-06-13 00:14:49 · 189 阅读 · 0 评论 -
LeetCode算法专题一:数组(2)
“Life is good!” 35.Search Insert Position Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. 我的基础太薄弱了!我知道要用原创 2020-06-03 07:01:30 · 174 阅读 · 0 评论 -
LeetCode算法专题一:数组
“加油啊,坚持下去吧!” 1.Two Sum 我遇到的问题:觉得解决思路很简单。但是因为想使用Java来写,居然有几点不知道如何下手。我怎么接收测试的数组??函数要返回一个数组,而这个数组的长度是2,我要怎么处理?? 后来惊讶的发现,只需要实现方法即可… class Solution { public int[] twoSum(int[] nums, int target) { int l = nums.length; for(int i=0;i<l;i++){原创 2020-05-28 07:05:37 · 268 阅读 · 0 评论 -
刷LeetCode动员大会!
“今天中大的老师打电话给我说补录的机会很小了,我真的要三战了!…” 我打算从今天开始刷LeetCode,使用国际版的,练好一点英语! 一共刷两遍,第一遍分类刷,第二遍按题号刷。 重点在于第一遍!!! 做每道题的步骤如下: 1.看懂题目 2.分析题意 3.写代码 4.至少看三个discussion,尽量找到最优解! 5.如果是新的知识点要先学习 5.写博客记录! “如果坚持就可以胜利的话,为什么不呢?” ...原创 2020-05-28 05:14:56 · 71 阅读 · 0 评论