목록알고리즘 (6)
개발 공부 기록 블로그

푼 문제 : 2974. Minimum Number Game 알고리즘 주제 : Sort알게 된 것 :- 자바 배열 정렬 메소드 Arrays.sort- 문제를 잘 읽자. 쓱 읽고 게임 이해를 잘 못해서 예시를 보고 stack에서 빼낸건 다시 넣는 문제라고 생각했다.run test case에서 바로 틀려서 보니 잘못 봤다.학습키워드 : #Sort #Arrays 제출본class Solution { public int[] numberGame(int[] nums) { Arrays.sort(nums); for (int i = 1; i 아래는 처음에 잘못 이해한 stack 코드class Solution { public int[] numberGame(int[] nums) { ..

푼 문제 :20. Valid Parentheses 알고리즘 주제 : Stack알게 된 것 :- Stack 선언- equals로 String 비교 (풀이엔 안쓰고 헤맬때 씀)- charAt 로 String의 char 별로 가져올 수 있음- GitHub - LeetCode 연동 (feat. LeetHub V2)학습키워드 : #Stack #CharAt #peek #push #equals 오랜만에 코딩테스트 문제를 풀어봤는데, 자주 봤던 주제인데도 테스트케이스 별로 해결하면서 풀었다.stack 선언도 오랜만이다. 문제 ) Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input st..
https://leetcode.com/problems/permutations/description/ Permutations - LeetCode Permutations - Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. Example 1: Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] Example 2: Input: nums = [0 leetcode.com Given an array nums of distinct integers, return al..
https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/ Letter Combinations of a Phone Number - LeetCode Letter Combinations of a Phone Number - Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digits to letters (just like on the telephone leetcode.co..
https://leetcode.com/problems/number-of-islands/submissions/887403414/ Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. Input: grid = [ ["1","1","1","1..
DFS(Depth-First-Search, 깊이 우선 탐색) 구현 - 재귀로 구현 위키피디아의 수도 코드 procedure DFS(G, v) is label v as discovered for all directed edges from v to w that are in G.adjacentEdges(v) do if vertex w is not labeled as discovered then recursively call DFS(G, w) 파이썬 구현 def recursive_dfs(v, discovered = []): discovered.append(v) for w in graph[v]: if w not in discovered: discovered = recursive_dfs(w, discovered) ..