博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
机器人又来运动了,我却坐了一天。
阅读量:3940 次
发布时间:2019-05-24

本文共 534 字,大约阅读时间需要 1 分钟。

在这里插入图片描述

剑指Offer做过一次,奈何没充分理解,又忘记了。

思路:之前上下左右都走,写完看别人写的发现只需向右向下就可以了。

(i/0+i%0+j/0+j%10)>k跳出。

class Solution {
public int movingCount(int m, int n, int k) {
boolean visited[][]= new boolean[m][n]; return rec(0,0,m,n,k,visited); } public int rec(int i,int j,int m,int n,int k,boolean[][] visited){
if(i>=m||j>=n||(i/10+i%10+j/10+j%10)>k||visited[i][j]){
return 0; } visited[i][j]=true; return rec(i+1,j,m,n,k,visited)+rec(i,j+1,m,n,k,visited)+1; }}

转载地址:http://jsnwi.baihongyu.com/

你可能感兴趣的文章
从2D恢复出3D的数据
查看>>
glm 中 数据类型 与 原始数据(c++ 数组)之间的转换
查看>>
Derivatives of scalars, vector functions and matrices
查看>>
the jacobian matrix and the gradient matrix
查看>>
VS2010 将背景设为保护色
查看>>
ubutun里面用命令行安装软件
查看>>
ubuntu 常用命令
查看>>
SQLite Tutorial 4 : How to export SQLite file into CSV or Excel file
查看>>
Optimizate objective function in matrix
查看>>
Convert polygon faces to triangles or quadrangles
查看>>
read obj in matlab
查看>>
find out the neighbour matrix of a mesh
查看>>
Operators and special characters in matlab
查看>>
As-Conformal-As-Possible Surface Registration
查看>>
qmake Variable Reference
查看>>
Lesson 2 Gradient Desent
查看>>
find border vertex
查看>>
matlab sliced variable
查看>>
create symbolic array
查看>>
TAUCS库的编译(vs2010)
查看>>