Skip to content

Commit 1013054

Browse files
committed
add ts solution for problem 442
1 parent 909d2d6 commit 1013054

File tree

2 files changed

+17
-1
lines changed
  • solution
    • 0400-0499/0442.Find All Duplicates in an Array
    • 2200-2299/2283.Check if Number Has Equal Digit Count and Digit Value

2 files changed

+17
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function findDuplicates(nums: number[]): number[] {
2+
for (let i = 0; i < nums.length; i++) {
3+
while (nums[i] !== nums[nums[i] - 1]) {
4+
const temp = nums[i];
5+
nums[i] = nums[temp - 1];
6+
nums[temp - 1] = temp;
7+
}
8+
}
9+
const ans: number[] = [];
10+
for (let i = 0; i < nums.length; i++) {
11+
if (nums[i] !== i + 1) {
12+
ans.push(nums[i]);
13+
}
14+
}
15+
return ans;
16+
}

solution/2200-2299/2283.Check if Number Has Equal Digit Count and Digit Value/Solution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ func digitCount(num string) bool {
99
}
1010
}
1111
return true
12-
}
12+
}

0 commit comments

Comments
 (0)