1 ganlanA

尚未进行身份认证

我要认证

暂无相关简介

等级
TA的排名 7w+

LeetCode 55. Jump Game (Greedy)

Given an array of non-negative integers, you are initially positioned at the first index of the array.给出一个非负整数数组,你的初始位置在数组的第一个下标。Each element in the array represents your maximum jump length at that position.数组中的每一个元素表示你在这个位置能跳跃的最大距离。Determine if you a

2020-07-04 00:56:42

LeetCode 54. Spiral Matrix 经典题目: 如何顺时针遍历二维数组

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.给定一个包含 m x n 个元素的矩阵(m 行, n 列),请按照顺时针螺旋顺序,返回矩阵中的所有元素。Example 1:Input:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]Output: [1,2,3,6,9,8,7,4,5]Exampl

2020-07-03 23:30:43

LeetCode 53. Maximum Subarray (DP) C++

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explanation: [4,

2020-07-03 16:03:20

LeetCode 52. N-Queens II 回溯法+约束编程 C++

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return the number of distinct solutions to the n-queens puzzle.n 皇后问题研究的是如何将 n 个皇后放置在 n×n 的棋盘上,并且使皇后彼此之间不能相互攻击。给定一个

2020-07-02 08:54:20

LeetCode 51. N-Queens 回溯法配合约束编程 C++

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.Each solution contains a distinct board configuration of the n-

2020-07-02 08:40:47

LeetCode 50. Pow(x, n) C++ 快速幂算法

Implement pow(x, n), which calculates x raised to the power n (xn).实现 pow(x, n) ,即计算 x 的 n 次幂函数。Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100Example 3:Input: 2.00000, -2Output: 0.25000Explanation: 2-2

2020-06-25 17:24:40

LeetCode 49. Group Anagrams (Hash Table) C++

Given an array of strings, group anagrams together.给定一个字符串数组,将字母异位词组合在一起。字母异位词指字母相同,但排列不同的字符串。Example:Input: ["eat", "tea", "tan", "ate", "nat", "bat"],Output:[ ["ate","eat","tea"], ["nat","tan"], ["bat"]]Note:All inputs will be in lowercase

2020-06-18 01:52:25

LeetCode 48. Rotate Image C++

You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotat

2020-06-18 01:17:06

LeetCode 47. Permutations II (Backtrack) C++

Given a collection of numbers that might contain duplicates, return all possible unique permutations.给定一个可包含重复数字的序列,返回所有不重复的全排列。Example:Input: [1,1,2]Output:[ [1,1,2], [1,2,1], [2,1,1]]C++class Solution {public: vector<vector<int&

2020-06-17 22:51:58

LeetCode 46. Permutations(Backtrack回溯法) C++

Given a collection of distinct integers, return all possible permutations.给定一个 没有重复 数字的序列,返回其所有可能的全排列。Example:Input: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]回溯法简介:回溯法就是树形问题上的DFS(深度优先遍历),内含有回溯的操作。状态: 求解问题的不

2020-06-17 11:53:40

LeetCode 45. Jump Game II (Greedy 贪心算法)C++

Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to reach the last index in the minimum number of jumps.给定一个

2020-06-17 10:43:08

LeetCode 44. Wildcard Matching (DP动态规划) C++

Given an input string (s) and a pattern §, implement wildcard pattern matching with support for ‘?’ and ‘*’.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire inpu

2020-06-16 01:42:55

LeetCode 43. Multiply Strings (竖式乘法)C++

Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.给定两个以字符串形式表示的非负整数 num1 和 num2,返回 num1 和 num2 的乘积,它们的乘积也表示为字符串形式。Example 1:Input: num1 = "2", num2 = "3"Output: "6"

2020-06-15 04:45:32

LeetCode 42. Trapping Rain Water (Two Pointers)

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。The above elevation map is represented by array [0,1,0

2020-06-11 21:07:16

LeetCode 41. First Missing Positive C++

Given an unsorted integer array, find the smallest missing positive integer.给你一个未排序的整数数组,请你找出其中没有出现的最小的正整数。Example 1:Input: [1,2,0]Output: 3Example 2:Input: [3,4,-1,1]Output: 2Example 3:Input: [7,8,9,11,12]Output: 1Note:Your algorithm should

2020-06-11 02:33:28

LeetCode 40. Combination Sum II (BackTrack) C++

Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.Each number in candidates may only be used once in the combination.Note:All numbers

2020-06-10 21:56:52

LeetCode 39. Combination Sum (回溯法 Backtrack + 去重分析) C++

Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.The same repeated number may be chosen from candidates unlimited number

2020-06-10 21:03:52

LeetCode 38. Count and Say C++

The count-and-say sequence is the sequence of integers with the first five terms as following:「外观数列」是一个整数序列,从数字 1 开始,序列中的每一项都是对前一项的描述。前五项如下:1. 12. 113. 214. 12115. 1112211 is read off as “one 1” or 11.11 is read off as “two 1s”

2020-06-10 13:01:46

LeetCode 37. Sudoku Solver (回溯法) C++

Write a program to solve a Sudoku puzzle by filling the empty cells.A sudoku solution must satisfy all of the following rules:Each of the digits 1-9 must occur exactly once in each row.Each of the digits 1-9 must occur exactly once in each column.Each

2020-06-10 11:50:39

LeetCode 36. Valid Sudoku C++ (Hash Table)

Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:Each row must contain the digits 1-9 without repetition.Each column must contain the digits 1-9 without repetition.Each of the 9 3x3 su

2020-06-08 07:21:13

查看更多

勋章 我的勋章
  • 签到新秀
    签到新秀
    累计签到获取,不积跬步,无以至千里,继续坚持!
  • 技术圈认证
    技术圈认证
    用户完成年度认证,即可获得
  • 阅读者勋章Lv2
    阅读者勋章Lv2
    授予在CSDN APP累计阅读博文达到7天的你,是你的坚持与努力,使你超越了昨天的自己。
  • 持之以恒
    持之以恒
    授予每个自然月内发布4篇或4篇以上原创或翻译IT博文的用户。不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!
  • 勤写标兵Lv4
    勤写标兵Lv4
    授予每个自然周发布9篇以上(包括9篇)原创IT博文的用户。本勋章将于次周周三上午根据用户上周的博文发布情况由系统自动颁发。