[leetcode 78] Subsets
Given a set of distinct integers, nums, return all possible subsets (the power set). 가능한 모든 부분집합을 구하라. Note: The solution set must not contain duplicate subsets. Example: Input: nums = [1,2,3] Output: [ [3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], [] ] 풀이: 전형적인 백트래킹 문제이다. cnt가 nums길이와 같아지면 종료하지만 그 전에 만들어지는 모든 경우의 수 역시 정답에 저장한다. class Solution { public: vector result; void BackTracking(int cnt, i..
2020. 10. 24.
[leetcode 79] Word Search
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where "adjacent" cells are horizontally or vertically neighboring. The same letter cell may not be used more than once. Example 1: Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED" Output: true Example 2: Input: board = [..
2020. 10. 22.