Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions missing-number/tedkimdev.rs
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

  • 패턴: Bit Manipulation
  • 설명: 이 코드는 XOR 연산을 활용하여 누락된 숫자를 찾는 비트 조작 기법을 사용합니다. XOR의 특성을 이용해 효율적으로 문제를 해결합니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(n) O(n)
Space O(1) O(1)

피드백: XOR 연산을 활용하여 배열 내 숫자와 인덱스를 모두 XOR하여 누락된 숫자를 찾는 효율적인 방법입니다. 시간 복잡도는 배열을 한 번 순회하므로 O(n), 공간은 상수입니다.

개선 제안: 현재 구현이 적절해 보입니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// TC: O(n)
// SC: O(1)
impl Solution {
pub fn missing_number(nums: Vec<i32>) -> i32 {
let n = nums.len() as i32;
let mut xor_result = n;
for i in 0..nums.len() {
xor_result ^= i as i32 ^ nums[i];
}
xor_result
}
}
Loading