Skip to content

Commit 32c8f2e

Browse files
edit 202
1 parent cdbc797 commit 32c8f2e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ Your ideas/fixes/algorithms are more than welcome!
384384
|206|[Reverse Linked List](https://leetcode.com/problems/reverse-linked-list/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_206.java)| O(n)|O(1) | Easy | Linked List
385385
|205|[Isomorphic Strings](https://leetcode.com/problems/isomorphic-strings/)|[Solution](../../blmaster/src/94fishercoder/algorithms/IsomorphicStrings.java)| O(n)|O(1) | Easy
386386
|204|[Count Primes](https://leetcode.com/problems/count-primes/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_204.java)| O(sqrt(n))|O(n) | Easy
387-
|202|[Happy Number](https://leetcode.com/problems/happy-number/)|[Solution](../master/src/main/java/com/fishercoder/solutions/HappyNumber.java)| O(k)|O(k) | Easy
387+
|202|[Happy Number](https://leetcode.com/problems/happy-number/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_202.java)| O(k)|O(k) | Easy
388388
|201|[Bitwise AND of Numbers Range](https://leetcode.com/problems/bitwise-and-of-numbers-range/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_201.java)| O(min(m,n))|O(1) | Medium | Bit Manipulation
389389
|200|[Number of Islands](https://leetcode.com/problems/number-of-islands/)|[Union Find](../master/src/main/java/com/fishercoder/solutions/_200UnionFind.java) [DFS](../master/MEDIUM/src/medium/_200DFS.java)| O(m*n)|O(m*n) | Medium| Union Find, DFS
390390
|199|[Binary Tree Right Side View](https://leetcode.com/problems/binary-tree-right-side-view/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_199.java)| O(n)|O(n)| Medium | BFS

src/main/java/com/fishercoder/solutions/HappyNumber.java renamed to src/main/java/com/fishercoder/solutions/_202.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33
import java.util.HashSet;
44
import java.util.Set;
55
/**Write an algorithm to determine if a number is "happy".
6-
7-
A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.
6+
A happy number is a number defined by the following process:
7+
Starting with any positive integer,
8+
replace the number by the sum of the squares of its digits,
9+
and repeat the process until the number equals 1 (where it will stay),
10+
or it loops endlessly in a cycle which does not include 1.
11+
Those numbers for which this process ends in 1 are happy numbers.
812
913
Example: 19 is a happy number
1014
1115
12 + 92 = 82
1216
82 + 22 = 68
1317
62 + 82 = 100
1418
12 + 02 + 02 = 1*/
15-
public class HappyNumber {
19+
public class _202 {
1620

1721
public static boolean isHappy(int n) {
1822
if(n == 1) return true;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy