Skip to content

Commit ddaefb6

Browse files
committed
fix 404 blog links
1 parent 17370a0 commit ddaefb6

File tree

5 files changed

+77
-77
lines changed

5 files changed

+77
-77
lines changed

201-300/205-isomorphic-strings.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
var isIsomorphic = function(s, t) {
2-
if(s.length !== t.length) return false;
3-
1+
var isIsomorphic = function (s, t) {
2+
if (s.length !== t.length) return false;
3+
44
const mapa = new Map();
55
const mapb = new Map();
6-
7-
for(let i=0;i<s.length;i++){
8-
if(mapa.has(s[i])){
9-
if(mapa.get(s[i]) !== t[i]){
10-
return false;
11-
}
12-
}else{
13-
mapa.set(s[i],t[i])
6+
7+
for (let i = 0; i < s.length; i++) {
8+
if (mapa.has(s[i])) {
9+
if (mapa.get(s[i]) !== t[i]) {
10+
return false;
1411
}
15-
16-
if(mapb.has(t[i])){
17-
if(mapb.get(t[i]) !== s[i]){
18-
return false;
19-
}
20-
}else{
21-
mapb.set(t[i],s[i])
12+
} else {
13+
mapa.set(s[i], t[i])
14+
}
15+
16+
if (mapb.has(t[i])) {
17+
if (mapb.get(t[i]) !== s[i]) {
18+
return false;
2219
}
20+
} else {
21+
mapb.set(t[i], s[i])
22+
}
2323
}
24-
24+
2525
return true
26-
26+
2727
};
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
var reverseVowels = function(s) {
1+
var reverseVowels = function (s) {
22
const arr = s.split("");
3-
4-
let left = 0,right = arr.length;
5-
6-
const vowels = ['A','E','I','O','U','a','e','i','o','u']
7-
8-
while(left<right){
9-
if(vowels.indexOf(arr[left]) === -1){
10-
left++;
11-
continue;
12-
}
13-
if(vowels.indexOf(arr[right]) === -1){
14-
right--;
15-
continue;
16-
}
17-
18-
const temp = arr[left];
19-
arr[left] = arr[right];
20-
arr[right] = temp;
21-
3+
4+
let left = 0, right = arr.length;
5+
6+
const vowels = ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u']
7+
8+
while (left < right) {
9+
if (vowels.indexOf(arr[left]) === -1) {
2210
left++;
11+
continue;
12+
}
13+
if (vowels.indexOf(arr[right]) === -1) {
2314
right--;
15+
continue;
16+
}
17+
18+
const temp = arr[left];
19+
arr[left] = arr[right];
20+
arr[right] = temp;
21+
22+
left++;
23+
right--;
2424
}
25-
25+
2626
return arr.join("")
2727
};
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
var guessNumber = function(n) {
2-
3-
if(guess(n) === 0) return n
4-
1+
var guessNumber = function (n) {
2+
3+
if (guess(n) === 0) return n
4+
55
let low = 1, high = n;
6-
while(n>0){
7-
const pick = (parseInt(high + low) / 2);
8-
const res = guess(pick);
9-
10-
if(res === 0){
11-
return pick
12-
}
13-
if(res === -1){
14-
high = pick;
15-
}
16-
if(res === 1){
17-
low = pick;
18-
}
6+
while (n > 0) {
7+
const pick = (parseInt(high + low) / 2);
8+
const res = guess(pick);
9+
10+
if (res === 0) {
11+
return pick
12+
}
13+
if (res === -1) {
14+
high = pick;
15+
}
16+
if (res === 1) {
17+
low = pick;
18+
}
1919
}
2020
};

301-400/383-ransom-note.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
var canConstruct = function(ransomNote, magazine) {
1+
var canConstruct = function (ransomNote, magazine) {
22
const map = new Map();
3-
4-
for(let i=0;i<magazine.length;i++){
5-
if(map.has(magazine[i])){
6-
map.set(magazine[i], map.get(magazine[i])+1)
7-
}else{
8-
map.set(magazine[i],1)
9-
}
3+
4+
for (let i = 0; i < magazine.length; i++) {
5+
if (map.has(magazine[i])) {
6+
map.set(magazine[i], map.get(magazine[i]) + 1)
7+
} else {
8+
map.set(magazine[i], 1)
9+
}
1010
}
11-
12-
for(let i=0;i<ransomNote.length;i++){
13-
if(!map.has(ransomNote[i]) || map.get(ransomNote[i]) === 0){
14-
return false;
15-
}
16-
map.set(ransomNote[i], map.get(ransomNote[i])-1)
11+
12+
for (let i = 0; i < ransomNote.length; i++) {
13+
if (!map.has(ransomNote[i]) || map.get(ransomNote[i]) === 0) {
14+
return false;
15+
}
16+
map.set(ransomNote[i], map.get(ransomNote[i]) - 1)
1717
}
18-
18+
1919
return true;
2020
};

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Solutions of all the questions from Leetcode in JavaScript.
88

99
# Questions
1010

11-
- 1.Two Sum - [Question](https://leetcode.com/problems/two-sum/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/1-two-sum.js) | [Blog](https://rishabh1403.com/leetcode-solution-of-two-sum-in-javascript) | [Youtube Video](https://www.youtube.com/watch?v=qqC9m93ofwI)
11+
- 1.Two Sum - [Question](https://leetcode.com/problems/two-sum/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/1-two-sum.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2019/11/leetcode-solution-of-two-sum-in-javascript) | [Youtube Video](https://www.youtube.com/watch?v=qqC9m93ofwI)
1212

13-
- 7.Reverse Integer - [Question](https://leetcode.com/problems/reverse-integer/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/7-reverse-integer.js) | [Blog](https://rishabh1403.com/leetcode-solution-of-reverse-integer-in-javascript) | [Youtube Video](https://www.youtube.com/watch?v=cIBwTqjh6VQ)
13+
- 7.Reverse Integer - [Question](https://leetcode.com/problems/reverse-integer/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/7-reverse-integer.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2019/11/leetcode-solution-of-reverse-integer-in-javascript) | [Youtube Video](https://www.youtube.com/watch?v=cIBwTqjh6VQ)
1414

15-
- 9.Palindrome Number - [Question](https://leetcode.com/problems/palindrome-number/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/9-palindrome-number.js) | [Blog](https://rishabh1403.com/leetcode-solution-of-palindrome-number-in-javascript) | [Youtube Video](https://youtu.be/7lCkkX3UAvU)
15+
- 9.Palindrome Number - [Question](https://leetcode.com/problems/palindrome-number/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/9-palindrome-number.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2019/12/leetcode-solution-of-palindrome-number-in-javascript) | [Youtube Video](https://youtu.be/7lCkkX3UAvU)
1616

1717
- 20.Valid Parentheses - [Question](https://leetcode.com/problems/valid-parentheses/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/1-100/20-valid-parentheses.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2019/09/leetcode-solution-of-valid-parentheses-in-javascript) | [Youtube Video](https://youtu.be/OuRH74PiPas)
1818

@@ -24,7 +24,7 @@ Solutions of all the questions from Leetcode in JavaScript.
2424

2525
- 125.Valid Palindrome - [Question](https://leetcode.com/problems/valid-palindrome/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/101-200/125-valid-palindrome.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/03/leetcode-valid-palindrome) | [Youtube Video](https://youtu.be/zqQRjBbwRew)
2626

27-
- 167.Two Sum-II - [Question](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/101-200/167-two-sum-ii.js) | [Blog](https://rishabh1403.com/leetcode-solution-of-two-sum-ii-in-javascript) | [Youtube Video](https://www.youtube.com/watch?v=MjxN8HIzIRc)
27+
- 167.Two Sum-II - [Question](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/101-200/167-two-sum-ii.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2019/12/leetcode-solution-of-two-sum-ii-in-javascript) | [Youtube Video](https://www.youtube.com/watch?v=MjxN8HIzIRc)
2828

2929
- 169.Majority Element - [Question](https://leetcode.com/problems/majority-element/) | [Source Code](https://github.com/rishabh1403/leetcode-javascript-solutions/blob/master/101-200/169-majority-element.js) | [Blog](https://rishabh1403.com/posts/coding/leetcode/2020/04/leetcode-majority-element) | [Youtube Video](https://youtu.be/p0vvs4Gq8qY)
3030

0 commit comments

Comments
 (0)