leetcode

it兼职以及行业门户网

左心房为你撑大大i 提交于 2020-02-15 15:48:48
程序员接私活的七大平台 https://www.jianshu.com/p/61a3fabe75fc 1、程序员客栈:程序员的经纪人 https://www.proginn.com/ 2、快码众包-让互联网产品开发更快速 https://www.kuai.ma/ 3、开源中国众包平台 oschina众包 https://zb.oschina.net/ 4、Coding 码市 - 云技术众包平台 https://coding.net/ coding除了是众包平台,还是代码托管平台 5、码易-高质量软件众包交付服务平台 https://www.mayigeek.com/ 6、人人开发 -让管理软件开发更容易 http://www.rrkf.com/ 7、开发邦-用技术支撑成长 http://www.kaifabang.com/ 8我推荐个任务栈 http://www.renwuzhan.top/ 不抽佣金,还可以自己联系客户,每天的任务也不少,app,网站开发,小程序,这些主流的开发项目 二、程序员常上的网站 给大家推荐程序员最常上的网站: 1. GitHub— 开发者最最最重要的网站:github.com这个不用多说了吧,是一个面向开源及私有软件项目的托管网站,上面有很多资源,需要就上去搜索,也有很多大牛的分享,可以学到很多知识,程序员必不可少的网站。 2

LeetCode All in One 题目讲解汇总(持续更新中...)

混江龙づ霸主 提交于 2020-02-15 10:42:13
Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may contain letters other than the parentheses ( and ) . Example 1: Input: "()())()" Output: ["()()()", "(())()"] Example 2: Input: "(a)())()" Output: ["(a)()()", "(a())()"] Example 3: Input: ")(" Output: [""] Credits: Special thanks to @hpplayer for adding this problem and creating all test cases. Subscribe to see which companies asked this question 这道题让移除最少的括号使得给定字符串为一个合法的含有括号的字符串,我们从小数学里就有括号,所以应该对合法的含有括号的字符串并不陌生,字符串中的左右括号数应该相同,而且每个右括号左边一定有其对应的左括号

LeetCode 22. 括号生成(Generate Parentheses)

不打扰是莪最后的温柔 提交于 2020-02-15 10:36:44
22. 括号生成 22. Generate Parentheses 题目描述 给出 n 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合。 例如,给出 n = 3,生成结果为: [ "((()))", "(()())", "(())()", "()(())", "()()()" ] LeetCode 22. Generate Parentheses 中等 回溯算法 Java 实现 import java.util.ArrayList; import java.util.List; class Solution { public List<String> generateParenthesis(int n) { List<String> list = new ArrayList<>(); backtrack(list, "", 0, 0, n); return list; } public void backtrack(List<String> list, String str, int open, int close, int max) { if (str.length() == max * 2) { list.add(str); return; } if (open < max) { backtrack(list, str + "(", open +

LeetCode | 0215. Kth Largest Element in an Array数组中的第K个最大元素【Python】

吃可爱长大的小学妹 提交于 2020-02-15 01:37:14
LeetCode 0215. Kth Largest Element in an Array数组中的第K个最大元素【Medium】【Python】【快排】【堆】 Problem LeetCode Find the k th largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 1: Input: [3,2,1,5,6,4] and k = 2 Output: 5 Example 2: Input: [3,2,3,1,2,4,5,5,6] and k = 4 Output: 4 Note: You may assume k is always valid, 1 ≤ k ≤ array’s length. 问题 力扣 在未排序的数组中找到第 k 个最大的元素。请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素。 示例 1: 输入: [3,2,1,5,6,4] 和 k = 2 输出: 5 示例 2: 输入: [3,2,3,1,2,4,5,5,6] 和 k = 4 输出: 4 说明: 你可以假设 k 总是有效的,且 1 ≤ k ≤ 数组的长度。

LeetCode 1103. Distribute Candies to People (分糖果 II)

大兔子大兔子 提交于 2020-02-13 17:08:11
题目标签:Math   题目让我们分发糖果,分的糖果从1 开始依次增加,直到分完。   for loop可以计数糖果的数量,直到糖果发完。但是还是要遍历array 给people 发糖,这里要用到 index = (本轮分糖果的量 % people 的人数)糖果的数量从0 开始计数,这样的话,index 就会一直重复遍历 array,具体看code。 Java Solution: Runtime: 1ms, faster than 90.53% Memory Usage: 33.8 MB, less than 100.00 % 完成日期:07/15/2019 关键点:利用%重复遍历array class Solution { public int[] distributeCandies(int candies, int num_people) { int[] people = new int[num_people]; for(int give = 0; candies > 0; candies -= give) { people[give % num_people] += Math.min(candies, ++give); } return people; } } 参考资料:LeetCode discuss LeetCode 题目列表 - LeetCode Questions

LeetCode All in One 题目讲解汇总(持续更新中...)

房东的猫 提交于 2020-02-12 03:51:03
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from the first array and one element from the second array. Find the k pairs (u1,v1),(u2,v2) ...(uk,vk) with the smallest sums. Example 1: Given nums1 = [1,7,11], nums2 = [2,4,6], k = 3 Return: [1,2],[1,4],[1,6] The first 3 pairs are returned from the sequence: [1,2],[1,4],[1,6],[7,2],[7,4],[11,2],[7,6],[11,4],[11,6] Example 2: Given nums1 = [1,1,2], nums2 = [1,2,3], k = 2 Return: [1,1],[1,1] The first 2 pairs are returned from the sequence: [1,1],[1,1]

LeetCode All in One 题目讲解汇总(持续更新中...)

谁说我不能喝 提交于 2020-02-12 00:23:10
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list. Example 1: Input: {"$id":"1","next":{"$id":"2","next":null,"random":{"$ref":"2"},"val":2},"random":{"$ref":"2"},"val":1} Explanation: Node 1's value is 1, both of its next and random pointer points to Node 2. Node 2's value is 2, its next pointer points to null and its random pointer points to itself. Note: You must return the copy of the given head as a reference to the cloned list. 这道链表的深度拷贝题的难点就在于如何处理随机指针的问题,由于每一个节点都有一个随机指针

[LeetCode] 6.Z 字形变换

我只是一个虾纸丫 提交于 2020-02-12 00:23:08
[LeetCode] 6.Z 字形变换 文章目录 [LeetCode] 6.Z 字形变换 题目 思路 题目 将一个给定字符串根据给定的行数,以从上往下、从左到右进行 Z 字形排列。 比如输入字符串为 "LEETCODEISHIRING" 行数为 3 时,排列如下: L C I R E T O E S I I G E D H N 之后,你的输出需要从左往右逐行读取,产生出一个新的字符串,比如: "LCIRETOESIIGEDHN" 。 请你实现这个将字符串进行指定行数变换的函数: string convert(string s, int numRows); 示例 1: 输入: s = "LEETCODEISHIRING", numRows = 3 输出: "LCIRETOESIIGEDHN" 示例 2: 输入: s = "LEETCODEISHIRING", numRows = 4 输出: "LDREOEIIECIHNTSG" 解释: L D R E O E I I E C I H N T S G 思路 找规律的题目 总共行数为 numRows ,那么我们只要依次从 numRows 个起点出发,按照规律间隔字符即可 这里的0行和最后一行比较特殊,因为其中的一个 s p a c e space s p a c e 为0,但是如果用0的话会出现一个字母被连续取两次的情况

LeetCode All in One 题目讲解汇总(持续更新中...)

◇◆丶佛笑我妖孽 提交于 2020-02-12 00:20:01
A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[A[i]]], ... } subjected to the rule below. Suppose the first element in S starts with the selection of element A[i] of index = i, the next element in S should be A[A[i]], and then A[A[A[i]]]… By that analogy, we stop adding right before a duplicate element occurs in S. Example 1: Input: A = [5,4,0,3,1,6,2] Output: 4 Explanation: A[0] = 5, A[1] = 4, A[2] = 0, A[3] = 3, A[4] = 1, A[5] = 6, A[6] = 2. One of the longest S[K]: S[0] = {A[0], A[5], A[6]

LeetCode All in One 题目讲解汇总(持续更新中...)

走远了吗. 提交于 2020-02-12 00:17:17
You are given a circular array nums of positive and negative integers. If a number k at an index is positive, then move forward k steps. Conversely, if it's negative (- k ), move backward k steps. Since the array is circular, you may assume that the last element's next element is the first element, and the first element's previous element is the last element. Determine if there is a loop (or a cycle) in nums . A cycle must start and end at the same index and the cycle's length > 1. Furthermore, movements in a cycle must all follow a single direction. In other words, a cycle must not consist of