Skip to content
Prev Previous commit
Next Next commit
another fix
  • Loading branch information
IvanMenov committed Nov 18, 2021
commit 910303ae4ab0080dff5161a84911689d0cd82485
8 changes: 6 additions & 2 deletions src/main/java/com_github_leetcode/ListNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) return false;
ListNode other = (ListNode) obj;
return val == other.val;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to compare ListNode by pointer, not by value.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ public String convertToTitle(int n) {
StringBuilder sb = new StringBuilder();
while (n != 0) {
int remainder = n % 26;
if (remainder == 0) remainder += 26;
if (remainder == 0) {
remainder += 26;
}
if (n >= remainder) {
n -= remainder;
sb.append((char) (remainder + 64));
Expand Down