File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ class Solution {
2+ List <Integer > list = new ArrayList <>();
3+ public int climbStairs (int n ) {
4+ list .add (0 );
5+ list .add (1 );
6+ list .add (2 );
7+ return step (n );
8+ }
9+
10+ public int step (int n ) {
11+ if (list .size () > n && list .get (n ) != null ) {
12+ return list .get (n );
13+ }
14+ int result = step (n - 1 ) + step (n - 2 );
15+ list .add (result );
16+ return result ;
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ class Solution {
2+ public boolean isAnagram (String s , String t ) {
3+ if (s .length () != t .length ()) {
4+ return false ;
5+ }
6+
7+ String [] sList = s .split ("" );
8+ Arrays .sort (sList );
9+ String [] tList = t .split ("" );
10+ Arrays .sort (tList );
11+
12+ for (int i = 0 ; i < s .length (); i ++) {
13+ // System.out.println(sList[i] + " " + tList[i]);
14+ if (!sList [i ].equals (tList [i ])) {
15+ return false ;
16+ }
17+ }
18+
19+ return true ;
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments