Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 84bc377

Browse files
author
ruislan
committed
solved q2022
1 parent 99036bc commit 84bc377

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

‎src/q/mod.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ mod q1846;
651651
mod q1877;
652652
mod q1893;
653653
mod q1894;
654+
mod q2022;
654655
mod q5818;
655656

656657
pub struct Solution;

‎src/q/q2022.rs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use crate::q::Solution;
2+
3+
#[allow(unused)]
4+
impl Solution {
5+
pub fn construct2_d_array(original: Vec<i32>, m: i32, n: i32) -> Vec<Vec<i32>> {
6+
// 方法1
7+
// 先检查以下m * n 是不是符合条件
8+
// 然后直接处理即可
9+
let l = original.len();
10+
let m = m as usize;
11+
let n = n as usize;
12+
if m * n != l { return vec![]; }
13+
let mut ans = vec![vec![0; n as usize]; m as usize];
14+
for i in 0..m {
15+
for j in 0..n {
16+
ans[i][j] = original[i * n + j];
17+
}
18+
}
19+
ans
20+
}
21+
}

‎src/q/q273.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ impl Solution {
66
// 方法1
77
// 3位算一组,然后每组里面计算百十个,然后外面得到十亿,百万,千
88
// 每组里面又分为了20以内(因为英文20以内是单个单词),20-100,以及100以上
9-
// AC 0ms 2mb
9+
// AC 0ms 2mb 601/601
1010
let singles = ["", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"];
1111
let teens = ["Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"];
1212
let tens = ["", "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
@@ -40,7 +40,7 @@ impl Solution {
4040
let mut i = 3;
4141
let mut unit = 1000000000;
4242
let mut num = num;
43-
while i < 4 && i >= 0{
43+
while i < 4 {
4444
let mut cur_num = num / unit;
4545
if cur_num != 0 {
4646
num -= cur_num * unit;

‎src/q/q846.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ impl Solution {
1414
let n = hand.len();
1515
let mut hand = hand;
1616
hand.sort_unstable();
17-
Ï
1817
let mut freq = HashMap::new();
1918
for i in 0..n {
2019
*freq.entry(hand[i]).or_insert(0) += 1;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /