File tree 2 files changed +20
-5
lines changed
2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 297
297
| 1099 | 🔒 [ Two Sum Less Than K] ( https://leetcode.com/problems/two-sum-less-than-k ) | | |
298
298
| 1103 | [ Distribute Candies to People] ( https://leetcode.com/problems/distribute-candies-to-people ) | [ ![ Java] ( assets/java.png )] ( src/DistributeCandiesToPeople.java ) | |
299
299
| 1108 | [ Defanging an IP Address] ( https://leetcode.com/problems/defanging-an-ip-address ) | [ ![ Java] ( assets/java.png )] ( src/DefangingAnIPAddress.java ) | |
300
- | 1118 | [ Number of Days in a Month] ( https://leetcode.com/problems/number-of-days-in-a-month ) | | |
301
- | 1119 | [ Remove Vowels From String] ( https://leetcode.com/problems/remove-vowels-from-a-string ) | | |
300
+ | 1118 | 🔒 [ Number of Days in a Month] ( https://leetcode.com/problems/number-of-days-in-a-month ) | | |
301
+ | 1119 | 🔒 [ Remove Vowels From String] ( https://leetcode.com/problems/remove-vowels-from-a-string ) | | |
302
302
| 1122 | [ Relative Sort Array] ( https://leetcode.com/problems/relative-sort-array ) | | |
303
303
| 1128 | [ Number of Equivalent Domino Pairs] ( https://leetcode.com/problems/number-of-equivalent-domino-pairs ) | [ ![ Java] ( assets/java.png )] ( src/NumberOfEquivalentDominoPairs.java ) | |
304
- | 1133 | [ Largest Unique Number] ( https://leetcode.com/problems/largest-unique-number ) | | |
305
- | 1134 | [ Armstrong Number] ( https://leetcode.com/problems/armstrong-number ) | | |
306
- | 1137 | [ Nth Tribonacci Number] ( ) | | |
304
+ | 1133 | 🔒 [ Largest Unique Number] ( https://leetcode.com/problems/largest-unique-number ) | | |
305
+ | 1134 | 🔒 [ Armstrong Number] ( https://leetcode.com/problems/armstrong-number ) | | |
306
+ | 1137 | [ Nth Tribonacci Number] ( https://leetcode.com/problems/n-th-tribonacci-number ) | [ ![ Java ] ( assets/java.png )] ( src/NthTribonacciNumber.java ) | |
307
307
| 1150 | [ Check if Number is Majority Element in Sorted Array] ( https://leetcode.com/problems/check-if-a-number-is-majority-element-in-a-sorted-array ) | | |
308
308
| 1154 | [ Day of The Year] ( https://leetcode.com/problems/day-of-the-year ) | | |
309
309
| 1160 | [ Find Words That Can Be Formed By Characters] ( https://leetcode.com/problems/find-words-that-can-be-formed-by-characters ) | | |
Original file line number Diff line number Diff line change
1
+ public class NthTribonacciNumber {
2
+ public int tribonacci (int n ) {
3
+ if (n == 0 ) return 0 ;
4
+ if (n <= 2 ) return 1 ;
5
+ int a = 0 , b = 1 , c = 1 , temp ;
6
+ while (n - 2 > 0 ) {
7
+ temp = c ;
8
+ c = a + b + c ;
9
+ a = b ;
10
+ b = temp ;
11
+ n --;
12
+ }
13
+ return c ;
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments