给定一个包含红色、白色和蓝色,一共 n 个元素的数组,原地对它们进行排序,使得相同颜色的元素相邻,并按照红色、白色、蓝色顺序排列。
Given a collection of distinct integers, return all possible permutations.
Given a collection of numbers, return all possible permutations.
LeetCode-HOT-100 力扣 (LeetCode) LeetCode 热题 HOT 100 ⚡ 如果你有问题 https://webvueblog.github.io/LeetCode-HOT
给定一个 m x n 二维字符网格 board 和一个字符串单词 word 。如果 word 存在于网格中,返回 true ;否则,返回 false 。
给定一个包含红色、白色和蓝色,一共 n 个元素的数组,原地对它们进行排序,使得相同颜色的元素相邻,并按照红色、白色、蓝色顺序排列。
Given two integers n and k, return all possible combinations of k numbers out of 1 … n.
//TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //TODO //T
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
others = current total += current return total Reference https://leetcode.com /problems/calculate-money-in-leetcode-bank/
在一个从左到右,从上到下均有序的二维数组中,找到从小到第k个数字,这里需要注意,不要求一定要是唯一的值,即假设存在这样一个序列1,2,2,3,则第三个数字是2而不是3。
2、复习以前学过的编程语言,LeetCode支持几乎所有主流编程语言,大家可以用不同语言来做题。 另外LeetCode的题型都非常简单明了,并不需要的复杂的理解,一般都在50行以内就可以解决了,如果你写了上百行代码,就肯定说明你想太多了或太复杂,虽然都能用很短的代码就能解决,但并不意味着LeetCode 的题目非常简单,实际上LeetCode基本上涉及到了所有常规的算法类型。 下面是我刷 LeetCode 的一些收获,希望能够引诱大家有空时刷刷题目。 千里之行,始于足下,接下来笔者讲讲如何使用leetcode。
给你一个包含 n 个整数的数组 nums,判断 nums 中是否存在三个元素 a,b,c ,使得 a + b + c = 0 ?请你找出所有和为 0 且不重复的三元组。
题目: Given a collection of numbers, return all possible permutations.
请看github:leetCode Given an array of integers, return indices of the two numbers such that they add up
遇到的输入链表如果没有空表头,一般给它加个空表头,便于设计算法,不用区分很多特殊情况。 如果算法可能设计前驱指针pre,则务必要加上空表头,因为当需要找到链表第一个节点的前驱指针时,没空表头会很难办。有空表头的话,第一个节点的前驱节点就是空表头。
题目描述 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and nums2 cannot be both empty. Example 1: nums1 = [1,
思路 遍历数组。维持一个max,表示当前数组应维持的最小的i,如果arr[i]大于max,就更新max为arr[i],然后如果i==max,也就说i已经到达最小要求,就cnt++,且max更新为数组下一个位置的值。 技巧度:B,思维绕脑度:B+ 主要是对arr[i], i 和max的关系情况分类的切入点要准。 详情 https://www.jianshu.com/p/82f3c0390b22
公司计划面试 2N 人。第 i 人飞往 A 市的费用为 costs[i][0],飞往 B 市的费用为 costs[i][1]。