- Input: matrix = [
- [1, 4, 7, 11, 15],
- [2, 5, 8, 12, 19],
- [3, 6, 9, 16, 22],
- [10, 13, 14, 17, 24],
- [18, 21, 23, 26, 30]
- ], target = 5
+ Input: matrix = [ [1, 4, 7, 11, 15], [2, 5, 8, 12, 19], [3, 6, 9,
+ 16, 22], [10, 13, 14, 17, 24], [18, 21, 23, 26, 30] ], target = 5
Output: {result ? "true" : "false"}
@@ -182,7 +178,7 @@ return (
```
-
+
```python
def searchMatrix(matrix: List[List[int]], target: int) -> bool:
@@ -259,7 +255,7 @@ return (
};
```
-
+
#### Complexity Analysis
@@ -269,7 +265,8 @@ return (
- The time complexity is linear in terms of the dimensions of the matrix. Each step eliminates either a row or a
- column, leading to a linear time complexity of $O(m + n)$.
+column, leading to a linear time complexity of $O(m + n)$.
+
- The space complexity is constant because we only use a few extra variables regardless of the matrix size.
@@ -287,8 +284,8 @@ This solution leverages the matrix's properties to reduce the search space effic
- ---
-
+---
+
@@ -306,7 +303,7 @@ This solution leverages the matrix's properties to reduce the search space effic
params="autoplay=1&autohide=1&showinfo=0&rel=0"
title="Search a 2D Matrix II Problem Explanation | Search a 2D Matrix II Solution"
poster="maxresdefault"
- webp
+ webp
/>
@@ -315,7 +312,7 @@ This solution leverages the matrix's properties to reduce the search space effic
params="autoplay=1&autohide=1&showinfo=0&rel=0"
title="Search a 2D Matrix II Problem Explanation | Search a 2D Matrix II Solution"
poster="maxresdefault"
- webp
+ webp
/>
@@ -328,7 +325,7 @@ This solution leverages the matrix's properties to reduce the search space effic
params="autoplay=1&autohide=1&showinfo=0&rel=0"
title="Search a 2D Matrix II Problem Explanation | Search a 2D Matrix II Solution"
poster="maxresdefault"
- webp
+ webp
/>
diff --git a/dsa-solutions/lc-solutions/0900-0999/0905-sort-array-by-parity.md b/dsa-solutions/lc-solutions/0900-0999/0905-sort-array-by-parity.md
index 4eacd7aa6..4278ec3fb 100644
--- a/dsa-solutions/lc-solutions/0900-0999/0905-sort-array-by-parity.md
+++ b/dsa-solutions/lc-solutions/0900-0999/0905-sort-array-by-parity.md
@@ -2,15 +2,15 @@
id: Sort-Array-By-Parity
title: Sort Array By Parity
sidebar_label: Sort Array By Parity
-tags:
- - Arrays
- - Sorting
+tags:
+ - Arrays
+ - Sorting
---
## Problem Description
-| Problem Statement | Solution Link | LeetCode Profile |
-| :------------------------------------------------------ | :------------------------------------------------------------------------- | :------------------------------------------------------ |
+| Problem Statement | Solution Link | LeetCode Profile |
+| :-------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------- | :--------------------------------------------------- |
| [Sort Array By Parity](https://leetcode.com/problems/sort-array-by-parity/description/) | [Sort Array By Parity Solution on LeetCode](https://leetcode.com/problems/sort-array-by-parity/solutions/) | [Nikita Saini](https://leetcode.com/u/Saini_Nikita/) |
## Problem Description
@@ -21,13 +21,13 @@ Return any array that satisfies this condition.
### Example 1:
-**Input:** `nums = [3, 1, 2, 4]`
-**Output:** `[2, 4, 3, 1]`
+**Input:** `nums = [3, 1, 2, 4]`
+**Output:** `[2, 4, 3, 1]`
**Explanation:** The outputs `[4, 2, 3, 1]`, `[2, 4, 1, 3]`, and `[4, 2, 1, 3]` would also be accepted.
### Example 2:
-**Input:** `nums = [0]`
+**Input:** `nums = [0]`
**Output:** `[0]`
## Constraints
@@ -64,7 +64,7 @@ public class EvenOddArray {
public static int[] sortArrayByParity(int[] nums) {
List even = new ArrayList<>();
List odd = new ArrayList<>();
-
+
for (int num : nums) {
if (num % 2 == 0) {
even.add(num);
@@ -72,11 +72,11 @@ public class EvenOddArray {
odd.add(num);
}
}
-
+
even.addAll(odd);
return even.stream().mapToInt(i -> i).toArray();
}
-
+
public static void main(String[] args) {
int[] nums = {3, 1, 2, 4};
System.out.println(Arrays.toString(sortArrayByParity(nums))); // Output: [2, 4, 3, 1]
@@ -122,7 +122,7 @@ int main() {
void sortArrayByParity(int* nums, int numsSize, int* returnSize) {
int* result = (int*)malloc(numsSize * sizeof(int));
int evenIndex = 0, oddIndex = numsSize - 1;
-
+
for (int i = 0; i < numsSize; ++i) {
if (nums[i] % 2 == 0) {
result[evenIndex++] = nums[i];
@@ -142,7 +142,7 @@ int main() {
int numsSize = sizeof(nums) / sizeof(nums[0]);
int returnSize;
sortArrayByParity(nums, numsSize, &returnSize);
-
+
for (int i = 0; i < numsSize; ++i) {
printf("%d ", nums[i]);
}
@@ -155,23 +155,23 @@ int main() {
```javascript
function sortArrayByParity(nums) {
- let even = [];
- let odd = [];
-
- for (let num of nums) {
- if (num % 2 === 0) {
- even.push(num);
- } else {
- odd.push(num);
- }
+ let even = [];
+ let odd = [];
+
+ for (let num of nums) {
+ if (num % 2 === 0) {
+ even.push(num);
+ } else {
+ odd.push(num);
}
-
- return [...even, ...odd];
+ }
+
+ return [...even, ...odd];
}
// Example usage
let nums = [3, 1, 2, 4];
-console.log(sortArrayByParity(nums)); // Output: [2, 4, 3, 1]
+console.log(sortArrayByParity(nums)); // Output: [2, 4, 3, 1]
```
## Step-by-Step Algorithm
@@ -185,4 +185,4 @@ console.log(sortArrayByParity(nums)); // Output: [2, 4, 3, 1]
## Conclusion
-This problem can be solved efficiently by iterating through the array once and separating the integers into even and odd lists/arrays. The time complexity is O(n), where n is the length of the array, making this approach optimal for the given constraints.
\ No newline at end of file
+This problem can be solved efficiently by iterating through the array once and separating the integers into even and odd lists/arrays. The time complexity is O(n), where n is the length of the array, making this approach optimal for the given constraints.
diff --git a/dsa-solutions/lc-solutions/0900-0999/0906-super-palindromes.md b/dsa-solutions/lc-solutions/0900-0999/0906-super-palindromes.md
index b4c6801dc..bdc410957 100644
--- a/dsa-solutions/lc-solutions/0900-0999/0906-super-palindromes.md
+++ b/dsa-solutions/lc-solutions/0900-0999/0906-super-palindromes.md
@@ -2,15 +2,15 @@
id: super-palindromes
title: Super Palindromes
sidebar_label: Super Palindromes
-tags:
- - Palindrome
- - Math
+tags:
+ - Palindrome
+ - Math
---
## Problem Description
-| Problem Statement | Solution Link | LeetCode Profile |
-| :------------------------------------------------------ | :------------------------------------------------------------------------- | :------------------------------------------------------ |
+| Problem Statement | Solution Link | LeetCode Profile |
+| :-------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------- | :--------------------------------------------------- |
| [Super Palindromes](https://leetcode.com/problems/super-palindromes/description/) | [Super Palindromes Solution on LeetCode](https://leetcode.com/problems/super-palindromes/solutions/) | [Nikita Saini](https://leetcode.com/u/Saini_Nikita/) |
## Problem Description
@@ -62,7 +62,7 @@ def super_palindromes(left, right):
left, right = int(left), int(right)
count = 0
limit = int(math.sqrt(right)) + 1
-
+
for i in range(1, limit):
s = str(i)
pal = s + s[::-1]
@@ -71,14 +71,14 @@ def super_palindromes(left, right):
break
if num >= left and is_palindrome(str(num)):
count += 1
-
+
pal = s + s[-2::-1]
num = int(pal) ** 2
if num > right:
break
if num >= left and is_palindrome(str(num)):
count += 1
-
+
return count
```
@@ -178,7 +178,7 @@ int superPalindromes(char* left, char* right) {
for (long long i = 1; i < limit; i++) {
sprintf(s, "%lld", i);
int len = strlen(s);
-
+
// Palindrome of even length
snprintf(pal, 40, "%s%s", s, strrev(strdup(s)));
long long num1 = atoll(pal) * atoll(pal);
@@ -200,28 +200,29 @@ int superPalindromes(char* left, char* right) {
```javascript
function isPalindrome(s) {
- return s === s.split('').reverse().join('');
+ return s === s.split("").reverse().join("");
}
function superPalindromes(left, right) {
- let l = BigInt(left), r = BigInt(right);
- let count = 0;
- let limit = BigInt(Math.sqrt(Number(r))) + BigInt(1);
-
- for (let i = BigInt(1); i < limit; i++) {
- let s = i.toString();
- let pal1 = s + s.split('').reverse().join('');
- let num1 = BigInt(pal1) ** BigInt(2);
- if (num1 > r) break;
- if (num1 >= l && isPalindrome(num1.toString())) count++;
-
- let pal2 = s + s.slice(0, -1).split('').reverse().join('');
- let num2 = BigInt(pal2) ** BigInt(2);
- if (num2 > r) break;
- if (num2 >= l && isPalindrome(num2.toString())) count++;
- }
-
- return count;
+ let l = BigInt(left),
+ r = BigInt(right);
+ let count = 0;
+ let limit = BigInt(Math.sqrt(Number(r))) + BigInt(1);
+
+ for (let i = BigInt(1); i < limit; i++) {
+ let s = i.toString();
+ let pal1 = s + s.split("").reverse().join("");
+ let num1 = BigInt(pal1) ** BigInt(2);
+ if (num1 > r) break;
+ if (num1 >= l && isPalindrome(num1.toString())) count++;
+
+ let pal2 = s + s.slice(0, -1).split("").reverse().join("");
+ let num2 = BigInt(pal2) ** BigInt(2);
+ if (num2 > r) break;
+ if (num2 >= l && isPalindrome(num2.toString())) count++;
+ }
+
+ return count;
}
```
@@ -230,12 +231,13 @@ function superPalindromes(left, right) {
1. **Generate Palindromes:**
- Iterate through possible values of `i` from 1 to the square root of the right boundary.
- Construct palindromes by concatenating `s` with its reverse and with its reverse minus the last character.
-
2. **Square Palindromes:**
+
- Compute the square of each palindrome.
- Check if the squared value is within the range `[left, right]`.
3. **Check for Super-Palindromes:**
+
- Verify if the squared palindrome is also a palindrome.
4. **Count and Return:**
diff --git a/src/data/courses/index.tsx b/src/data/courses/index.tsx
index f25b7a8d5..a77af4f20 100644
--- a/src/data/courses/index.tsx
+++ b/src/data/courses/index.tsx
@@ -31,10 +31,10 @@ const courses = [
imageUrl: "/img/svg/static_assets.svg",
author: "Ajay Dhangar",
link: "/docs/category/javascript"
- },
-
+ },
+
// React for beginners
-
+
{
id: 5,
title: "React for Beginners",
@@ -46,7 +46,7 @@ const courses = [
},
// angular for beginners
-
+
// {
// id: 6,
// title: "Angular for Beginners",
@@ -351,6 +351,5 @@ const courses = [
"link": "https://www.figma.com/resources/learn-design/"
},
];
-
+
export default courses;
-
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index 02f16057c..66bd42804 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -137,7 +137,7 @@ export default function Home() {
-