본문 바로가기

분류 전체보기

(2349)
2026-07-04 보호되어 있는 글입니다.
2026-07-03 보호되어 있는 글입니다.
2026-07-02 보호되어 있는 글입니다.
(Rust) - LeetCode (Easy) : 3120. Count the Number of Special Characters I https://leetcode.com/problems/count-the-number-of-special-characters-i Count the Number of Special Characters I - LeetCodeCan you solve this real interview question? Count the Number of Special Characters I - You are given a string word. A letter is called special if it appears both in lowercase and uppercase in word. Return the number of special letters in word. Example 1leetcode.comvector 자료..
(Rust) - LeetCode (Medium) : 1391. Check if There is a Valid Path in a Grid https://leetcode.com/problems/check-if-there-is-a-valid-path-in-a-grid Check if There is a Valid Path in a Grid - LeetCodeCan you solve this real interview question? Check if There is a Valid Path in a Grid - You are given an m x n grid. Each cell of grid represents a street. The street of grid[i][j] can be: * 1 which means a street connecting the left cell and the right cellleetcode.com기존의 단순 b..
(Rust) - LeetCode (Easy) : 342. Power of Four https://leetcode.com/problems/power-of-fourpow함수를 써보는 문제였습니다.📕 풀이방법📔 풀이과정📑 시간 복잡도16번만 수행하면 되므로 O(1) 입니다📑 공간 복잡도상수 공간을 사용하므로 O(1) 입니다.📔 정답 출력 | 반환n의 범위가 2^32이므로 4^16까지 for loop를 수행하며 n이랑 같다면 true를 반환하면됩니다.📕 Code📔 Rustimpl Solution { pub fn is_power_of_four(n: i32) -> bool { if n == 0 { return false; } for i in 0..=16 { if 4_i32.pow(i) == n { ..
(Rust) - LeetCode (Easy) : 3477. Fruits Into Baskets II https://leetcode.com/problems/fruits-into-baskets-ii/description전수조사로 해결한 문제였습니다.📕 풀이방법📔 입력 및 초기화i번째 바구니를 사용했는지 여부를 확인하기 위해 vector checked 변수를 mut으로 선언해줍니다.📔 풀이과정📑 i번째 fruit를 담을 j번째 basket 크기를 비교fruits에 대해 iter수행하며 for_each마다 basket에 enumerate 했을 때 j번째가 현재 fruit 이상이라면 담을 수 있으므로 j번째 checked 를 true로 바꿔줍니다. 📑 checked배열에서 false인 값을 변수 unplaced 📑 시간 복잡도O(n^2)📑 공간 복잡도O(n)📔 정답 출력 | 반환unplaced를 ..
(Rust) - LeetCode (Easy) : 1979. Find Greatest Common Divisor of Array https://leetcode.com/problems/find-greatest-common-divisor-of-array/description/gcd를 사용해본 문제였습니다.📕 풀이방법📔 입력 및 초기화유클리드 호제법으로 gcd를 반환할 함수를 구현합니다. 시간복잡도는 O(logN)을 가집니다.📔 풀이과정nums의 최댓값, 최솟값을 뽑아 값이 있는 경우 max_num, min_num변수에 저장합니다.📑 시간 복잡도O(logN)📑 공간 복잡도O(N)📔 정답 출력 | 반환 값이 있는 경우 두 변수의 gcd값을 반환하며 아닌 경우 아무의미 없는 값 0을 반환합니다. if let문은 해당 분기 외의 조건에도 반환값을 강제하기 때문입니다.📕 Code📔 Rustuse std::cmp::max;impl..