Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ace8eca
1914. Cyclically Rotating a Grid
SinnoLn Nov 3, 2026
9f042db
Create 1861. Rotating the Box.py
724thomas Nov 3, 2026
439b0fe
Create 1914. Cyclically Rotating a Grid.py
724thomas Nov 3, 2026
ca467cc
1914
rimgosu Nov 3, 2026
ff2a9b9
Merge pull request #2249 from CodingTestStudy2/곽현지
724thomas Nov 3, 2026
eb98a7d
Create copy
724thomas Nov 3, 2026
c812d88
Create copy
724thomas Nov 3, 2026
27d04d4
Create 1914. Cyclically Rotating a Grid
oheunhyuck Nov 3, 2026
7e871bf
Create 1861. Rotating the Box
oheunhyuck Nov 3, 2026
a0912bd
1914. Cyclically Rotating a Grid
Zuhye Nov 3, 2026
44d264a
Merge pull request #2253 from CodingTestStudy2/곽현지
github-actions[bot] Nov 3, 2026
c23c503
Merge pull request #2252 from CodingTestStudy2/오은혁
github-actions[bot] Nov 3, 2026
203a989
Merge pull request #2251 from CodingTestStudy2/송주혜
github-actions[bot] Nov 3, 2026
77e4c74
Merge pull request #2248 from CodingTestStudy2/변지협
github-actions[bot] Nov 3, 2026
e69f77d
Merge pull request #2247 from CodingTestStudy2/최원준
github-actions[bot] Nov 3, 2026
790a199
Merge pull request #2246 from CodingTestStudy2/이진희
github-actions[bot] Nov 3, 2026
d9cd06f
Create 442. Find All Duplicates in an Array
oheunhyuck Nov 3, 2026
40f2e2d
442. Find All Duplicates in an Array
SinnoLn Nov 4, 2026
69eca60
Create 442. Find All Duplicates in an Array.py
724thomas Nov 4, 2026
aea2932
Update 442. Find All Duplicates in an Array.py
724thomas Nov 4, 2026
77cdd98
Implement findDuplicates function to identify duplicates
Zuhye Nov 4, 2026
50da045
Merge pull request #2257 from CodingTestStudy2/송주혜
github-actions[bot] Nov 4, 2026
dcc0fee
Merge pull request #2256 from CodingTestStudy2/최원준
github-actions[bot] Nov 4, 2026
57e5dd3
Merge pull request #2255 from CodingTestStudy2/이진희
github-actions[bot] Nov 4, 2026
43b9892
Merge pull request #2254 from CodingTestStudy2/오은혁
github-actions[bot] Nov 4, 2026
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
63 changes: 63 additions & 0 deletions leetcode3/변지협/v4/1914. Cyclically Rotating a Grid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'''
시간 초과
'''
'''
0,0 -> 0,1
0,1 -> 0,2
...
0,4 -> 0,5
0,5 -> 1,5
1,5 -> 2,5
2,5 -> 3,5
3,5 -> 3,4
'''
class Solution:
def rotate_one(self, grid: List[List[int]]) -> List[List[int]]:
xlen = len(grid[0])
ylen = len(grid)
vertexs = [(0,0),(0,ylen-1),(xlen-1,ylen-1),(xlen-1,0)]
rotate_num = min(xlen,ylen) // 2
tmp = [[0] * xlen for _ in range(ylen)]

while rotate_num > 0:
# print(rotate_num)
# print(vertexs)

for y in range(vertexs[0][1],vertexs[1][1]):
tmp[y+1][vertexs[0][0]] = grid[y][vertexs[0][0]]

# print(tmp)

for x in range(vertexs[1][0],vertexs[2][0]):
tmp[vertexs[1][1]][x+1] = grid[vertexs[1][1]][x]

# print(tmp)

for y in range(vertexs[2][1],vertexs[3][1],-1):
tmp[y-1][vertexs[2][0]] = grid[y][vertexs[2][0]]

# print(tmp)

for x in range(vertexs[3][0],vertexs[0][0],-1):
tmp[vertexs[3][1]][x-1] = grid[vertexs[3][1]][x]

tmp2 = [
(vertexs[0][0]+1,vertexs[0][1]+1),
(vertexs[1][0]+1,vertexs[1][1]-1),
(vertexs[2][0]-1,vertexs[2][1]-1),
(vertexs[3][0]-1,vertexs[3][1]+1)
]
vertexs = tmp2
rotate_num -= 1
return tmp

def rotateGrid(self, grid: List[List[int]], k: int) -> List[List[int]]:
tmp = grid

xlen = len(grid[0])
ylen = len(grid)

while k > 0:
tmp = self.rotate_one(tmp)
k-=1
return tmp
28 changes: 28 additions & 0 deletions leetcode3/송주혜/1914. Cyclically Rotating a Grid
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class Solution:
def rotateGrid(self, grid: List[List[int]], k: int) -> List[List[int]]:
m = len(grid)
n = len(grid[0])

minLen = min(m, n)

for i in range(minLen //2):
for j in range(k): # k만큼 돌기
tmp = grid[i][i]

for k in range(i, n-1): # <-
grid[i][k] = grid[i][k+1]
for k in range(i, m-1): # ^
grid[k][n-1] = grid[k+1][n-1]
for k in range(n-1, i, -1): # ->
grid[m-1][k] = grid[m-1][k-1]
for k in range(m-1, i, -1):
grid[k][i] = grid[k-1][i]

grid[i+1][i] = tmp

return grid


/**
수정해야함
**/
16 changes: 16 additions & 0 deletions leetcode3/송주혜/442. Find All Duplicates in an Array
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution:
def findDuplicates(self, nums: list[int]) -> list[int]:
ans = []
numbers = {}

for i in nums:
if i in numbers:
numbers[i] += 1
else:
numbers[i] = 1

for i in numbers:
if numbers[i] ==2:
ans.append(i)

return ans
13 changes: 13 additions & 0 deletions leetcode3/송주혜/copy
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#

'''
1. 아이디어 :


2. 시간복잡도 :
O()

3. 자료구조/알고리즘 :


'''
11 changes: 11 additions & 0 deletions leetcode3/오은혁/1861. Rotating the Box
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution:
def rotateTheBox(self, grid: list[list[str]]) -> list[list[str]]:


for y in range(len(grid))
board=[[] for _ in range(len(grid[0]))]
for y in grid:
for i in range(len(y)):
board[i].append(y[i])


46 changes: 46 additions & 0 deletions leetcode3/오은혁/1914. Cyclically Rotating a Grid
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from collections import deque
class Solution:
def rotate(self,grid,x,y,xn,yn,k):
dq=deque([])
cur_x=x
cur_y=y
while cur_x<x+xn:
dq.append((cur_y,cur_x))
cur_x+=1
cur_x-=1
cur_y+=1
while cur_y<y+yn:
dq.append((cur_y,cur_x))
cur_y+=1
cur_y-=1
cur_x-=1
while cur_x>=x:
dq.append((cur_y,cur_x))
cur_x-=1
cur_x+=1
cur_y-=1
while cur_y>y:
dq.append((cur_y,cur_x))
cur_y-=1
return dq
temp=yn*xn-(yn-2)*(xn-2)
k=k%temp

if k<yn:
sx=x
sy=y+k
elif k>=yn and k<yn+xn-1:
sx=k-yn+1
sy=yn-1

elif k<2*yn+xn-2:
sx=xn-1
sy=k-yn-xn

else:
sx=
sy=y


def rotateGrid(self, grid: List[List[int]], k: int) -> List[List[int]]:
return self.rotate(grid,0,0,len(grid[0]),len(grid),k)
33 changes: 33 additions & 0 deletions leetcode3/오은혁/442. Find All Duplicates in an Array
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class Solution:
def c(self,nums,t):

if isinstance(nums[t],int):
temp=nums[t]
nums[t]='1'
self.c(nums,temp-1)
elif nums[t]=='.':
nums[t]='1'
else:
nums[t]=str(int(nums[t])+1)

def findDuplicates(self, nums: list[int]) -> list[int]:
ans=[]
for i in range(len(nums)):
if isinstance(nums[i],int):
if nums[i]==i+1:
nums[i]='1'
else:
temp=nums[i]
nums[i]='.'
self.c(nums,temp-1)


else:continue

for i in range(len(nums)):
if nums[i]=='2':
ans.append(i+1)
return ans



13 changes: 13 additions & 0 deletions leetcode3/오은혁/copy
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#

'''
1. 아이디어 :


2. 시간복잡도 :
O()

3. 자료구조/알고리즘 :


'''
70 changes: 70 additions & 0 deletions leetcode3/이진희/1914. Cyclically Rotating a Grid.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*

1. 아이디어 : 방문 배열과 이동 방향을 미리 정의 후, i,i부터 아래 -> 오른쪽 -> 위 -> 왼쪽 경로의 원소 위치 수집
k번 만큼 회전(이동)한 위치에 넣는다 - 모듈러 연산 필요


2. 시간복잡도 : O(2*N*M)

3. 자료구조/알고리즘 : 방향 전환, 배열

*/

class Solution {
private boolean[][] visited;
private int[][] ans;
private int[] dy = {0,1,0,-1};
private int[] dx = {-1,0,1,0};
public int[][] rotateGrid(int[][] grid, int k) {
// m, n은 짝수
// k 횟수 만큼 왼쪽 회전

visited = new boolean[grid.length][grid[0].length];
ans = new int[grid.length][grid[0].length];
int limit = Math.min(grid.length, grid[0].length)/2;
for(int i=0; i<limit; i++) {
rotate(i,i,grid,k);
}

return ans;
}

private void rotate(int y, int x, int[][] grid, int k) {
List<int[]> list = new ArrayList<>();
visited[y][x] = true;
list.add(new int[]{y,x});

int startY = y;
int startX = x;

// 아래 방향
int dir = 1;
while(true) {
int ny = y+dy[dir];
int nx = x+dx[dir];

if(ny == startY && nx == startX) break;

if(ny<0 || nx<0 || ny>=grid.length || nx>=grid[0].length || visited[ny][nx]) {
dir=(dir+1)%4;
continue;
}

y = ny;
x = nx;

visited[y][x] = true;
list.add(new int[]{y,x});
}

int size = list.size();
int move = k%size;

for(int i=0; i<size; i++) {
int[] original = list.get(i);
int[] tmp = list.get((i+move)%size);

ans[tmp[0]][tmp[1]] = grid[original[0]][original[1]];
}
}
}
30 changes: 30 additions & 0 deletions leetcode3/이진희/442. Find All Duplicates in an Array.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*

1. 아이디어 : 초반 SWAP으로 각 위치를 교환하려고 했으나 예외케이스가 늘어나 실패
추가 공간 복잡도를 활용할 수 없고 각 nums[i]의 범위가 1<=nums[i]<=n인것을 바탕으로 숫자를 만났을때 음수를 붙여 이미 본 적있는지 체크

2. 시간복잡도 : O(N)

3. 자료구조/알고리즘 : 부호 반전

*/

class Solution {
// 각 원소는 최대 두 번 등장
// 시간복잡도 O(N)
// 추가 공간은 배열의 크기에 따라가 변하지 않고 고정적이어야 함
// 답을 위한 추가 공간 제외
// 두번 등장하는 모든 윈소를 출력 (출력 순서는 상관 없음)
public List<Integer> findDuplicates(int[] nums) {
List<Integer>ans = new ArrayList<>();

for(int i=0; i<nums.length; i++) {
int num = Math.abs(nums[i]);

if(nums[num-1] < 0) ans.add(num);
else nums[num-1] = -nums[num-1];
}

return ans;
}
}
61 changes: 61 additions & 0 deletions leetcode3/최원준/1861. Rotating the Box.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#

'''
1. 아이디어 :
- 돌을 오른쪽으로 미는 메서드
오른쪽으로 밀때는 장애물을 만나기전까지 돌을 센 후, 장애물을 만나거나 끝까지 가면 다시 뒤로 가며 돌로 채운다.

- 90도로 회전하는 메서드

2. 시간복잡도 :
O(n * m * m)

3. 자료구조/알고리즘 :
-

'''
class Solution:
def rotateTheBox(self, boxGrid: list[list[str]]) -> list[list[str]]:
n = len(boxGrid)
m = len(boxGrid[0])

def push_right(box):
for row in box:
stones = 0
for i in range(m):
cell = row[i]
if cell == "#":
stones += 1
row[i] = "."
elif cell == ".":
pass
elif cell == "*":
for j in range(i-1, i-1-stones,-1):
row[j] = "#"
stones = 0
for i in range(m-1, m-1-stones, -1):
row[i] = "#"
return box

boxGrid_push = push_right(boxGrid)


def rotate_90(box):
boxGrid90 = [[[""] for _ in range(n)] for _ in range(m)]
for i in range(n):
for j in range(m):
boxGrid90[j][n-i-1] = box[i][j]
return boxGrid90

return rotate_90(boxGrid_push)

"""
[["#",".","*","."]
["#","#","*","."]]
[
[[''], ['']],
[[''], ['']],
[[''], ['']],
[[''], ['']]
]
"""
Loading
Loading