当前位置:网站首页>Daily question (retrospective)
Daily question (retrospective)
2022-07-28 15:19:00 【Dream fish YX】
①、 subject
cookies :
Power button
https://leetcode.cn/problems/assign-cookies/
route :
Power button
https://leetcode.cn/problems/all-paths-from-source-to-target/
②、 Problem solving
cookies :
class Solution {
public int findContentChildren(int[] g, int[] s) {
// Try to satisfy children with small appetites , On this basis, try to use small cookies
Arrays.sort(g);
Arrays.sort(s);
int answer=0;
for (int i=0,j=0; i < g.length && j < s.length; j++) {
if (g[i]<=s[j]){
answer++;
i++;
}
}
return answer;
}
}route :
class Solution {
private int[][] graph;
private List<List<Integer>> answer=new ArrayList<>();
public List<List<Integer>> allPathsSourceTarget(int[][] graph) {
this.graph=graph;
ArrayList<Integer> list = new ArrayList<>();
list.add(0);
dfc(0,list);
return answer;
}
private void dfc(int a,List<Integer> temp){
// Come to No n-1 Nodes : Satisfy , End
if (a==graph.length-1)
// Can't directly temp add to , Otherwise after temp change ,answer The inside also changes
// Because they point to the same address
answer.add(new ArrayList<Integer>(temp));
for (int i = 0; i < graph[a].length; i++) {
temp.add(graph[a][i]);
dfc(graph[a][i],temp);
// to flash back :
temp.remove(temp.size()-1);
}
}
}③、 Run a screenshot

边栏推荐
- 3511. 倒水问题
- 回编译失败
- In 2022, the average salary of global programmers was released, and China ranked unexpectedly
- Three pop-up boxes commonly used in JS
- crmeb pro2.2即将增加的功能都有哪些?
- 全开源免费的客服系统来了
- An idea of modifying vertex height with shader vertex shader
- Srtt-110vdc-4h-c time relay
- Customer service system attached to crmeb Standard Edition
- ERROR:bokeh.core.validation.check:E-1001 (BAD_COLUMN_NAME)
猜你喜欢

The difference between @notnull, @notblank, @notempty of commonly used verification annotations

Apple iPhone app icon hidden how to retrieve and restore the hidden app icon displayed on the iPhone iPhone desktop to the iPhone iPhone iPhone desktop?

crmeb标准版附带的客服系统

JWY-32B电压继电器

Install MOSEK, license installation location search

Instant experience | further improve application device compatibility with cts-d

R introduction example details

shellcode编写学习-环境

The automatic prompt of vs code code is missing - a tick to solve it

SRTT-110VDC-4H-C时间继电器
随机推荐
Understand crmeb open source online education knowledge payment system
Enterprise wechat customer service link, enterprise wechat customer service chat
Publish raspberry pie web page with cpolar (apache2 installation test)
Customer service system attached to crmeb Standard Edition
使用cpolar发布树莓派网页(apache2的安装测试)
Three pain points of software development! How to solve the applet container?
Shader顶点着色器修改顶点高度的一个思路
DAY:7/11
The modified network card name of rocky foundation is eth0
JS study notes 18-23
3511. 倒水问题
Instructions for common symbols in kotlin
3588. Permutation and binary
3477. 简单排序
Apple iPhone app icon hidden how to retrieve and restore the hidden app icon displayed on the iPhone iPhone desktop to the iPhone iPhone iPhone desktop?
新版数据同步问题
What are the main threats to cloud security
JS学习笔记24-28:结束
封装统一返回对象MessageResult
Compilation failure caused by kotlin version upgrade