public class Solution {
public boolean canJump(int[] nums) {
int n = nums.length;
int rightmost = 0;
for (int i =...
class Solution {
public:
int numSquares(int n) {
vector<int> f(n + 1);
for (int i = 1; i <= n; i++) {
...
class Solution {
public:
int maxArea(vector<int>& height) {
int l = 0, r = height.size()-1;
int ans = 0;
...
class Solution {
public:
int maxProduct(vector<int>& nums) {
//f1,f2:以第i个数结尾的乘积最大,最小的子数组乘积。
//最小的对应负数的情况,负负得正。
...
class Solution {
public:
int longestConsecutive(vector<int>& nums) {
unordered_set<int>se;
for(int x: num...
class Solution {
public:
int maxProfit(vector<int>& prices) {
if(prices.size()==0)return 0;
//f[i]到第i天为止的最大收益。
...
//f[i][j]表示s的前i个能否被p的前j个匹配。
//转移若s[i]==p[j]则f[i][j]=f[i-1][j-1]. 否则若p[j]=.也可以匹配,若=*则再判断p[j-1]与s[i]的关系
class Solution {
public:
bool isMat...
class Solution {
public:
vector<int> findAnagrams(string s, string p) {
int slen = s.size(), plen = p.size();
if(sl...
class Solution {
public:
int trap(vector<int>& height) {
int ans = 0;
int left = 0, right = height.size() - 1;
...
class Solution {
public:
int countSubstrings(string s) {
int n = s.size(), ans = 0;
for(int i = 0; i < 2*n-1; i++){
...
class Solution {
public:
int longestValidParentheses(string s) {
int ans = 0;
stack<int>stk;
stk.push(-1);...
class Solution {
public:
vector<int> dailyTemperatures(vector<int>& temperatures) {
int n = temperatures.size();
...
class Solution {
public:
vector<double> calcEquation(vector<vector<string>>& equations, vector<double>& val...
class Solution {
public:
bool check(string s){ //判断序列是否合法
int cc = 0;
for(char ch : s){
if(ch=='(')cc++;
...
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNo...
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNo...
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNo...
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNo...
#include <iostream>
using namespace std;
int main() {
long long int n, count = 0;
cin >> n;
for (long long...
#include<bits/stdc++.h>
using namespace std;
const int dir[8][2] = { {1,2},{1,-2},{2,1},{2,-1},{-1,2},{-1,-2},{-2,1},{-2,-1} };
bool d[3...
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0 ...