Java 内置的数据类型
Java 可分为两大数据类型:
- 内置数据类型(Primitive)
- 引用数据类型(Reference)
LeetCode 解题报告 (48)-- 矩阵的旋转
原题如下: You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up: Could you do this in-place?
LeetCode 解题报告 (46,47)-- 排列
46. Permutations
原题如下:
Given a collection of distinct numbers, return all possible permutations.
LeetCode 解题报告 (42)-- 柱状图的储水量
原题如下 >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.
LeetCode 解题报告 (41)-- 第一个缺失的正整数
原题如下:
Given an unsorted integer array, find the first missing positive integer.
LeetCode 解题报告 (39,40)-- 数字集合中找特定和
这两道题目 39. Combination Sum和 40. Combination Sum II均要求从给定的一个数字集合中找出若干个数字的和等于某个给定的数。解决方法有两种,第一种是回溯法,第二种是动态规划。下面分别讲述。
LeetCode 解题报告 (37)-- 回溯法解决数独问题
原题如下: >Write a program to solve a Sudoku puzzle by filling the empty cells.
Empty cells are indicated by the character '.'.
LeetCode 解题报告 (33,81,153,154)-- 二分搜索找旋转数组特定值
本文主要讲述如何在一个
Rotated Sorted Array
中找到特定的值,Rotated Sorted Array
指旋转了的数组,如4 5 6 7 0 1 2
就是0 1 2 4 5 6 7
的一个旋转数组。正常情况下遍历一遍即可,但是这样的时间复杂度为 \(O(n)\), 但是本文主要讲述通过二分查找将时间复杂度降到 \(O(log_2n)\)。LeetCode 解题报告 (32)-- 最长合法的子括号串
原题如下:
>Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.
LeetCode 解题报告 (31)-- 数字排列的下一项
原题如下:
>Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
0%