File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ class Solution {
2+ public int climbStairs (int n ) {
3+ int [] memo = new int [n + 1 ];
4+ return recur (n , memo );
5+ }
6+
7+ int recur (int n , int [] memo ) {
8+ if (n < 0 ) {
9+ return 0 ;
10+ }
11+
12+ if (n == 0 ) {
13+ return 1 ;
14+ }
15+
16+ if (memo [n ] > 0 ) {
17+ return memo [n ];
18+ }
19+
20+ memo [n ] = recur (n - 1 , memo ) + recur (n - 2 , memo );
21+ return memo [n ];
22+ }
23+ }
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+ char [] sArray = s .toCharArray ();
8+ Arrays .sort (sArray );
9+
10+ char [] tArray = t .toCharArray ();
11+ Arrays .sort (tArray );
12+
13+ for (int i = 0 ; i < sArray .length ; i ++) {
14+ if (sArray [i ] != tArray [i ]) {
15+ return false ;
16+ }
17+ }
18+ return true ;
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments