분류 전체보기351 [leetcode 416] Partition Equal Subset Sum Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal. Note: Each of the array element will not exceed 100. The array size will not exceed 200. Example 1: Input: [1, 5, 11, 5] Output: true Explanation: The array can be partitioned as [1, 5, 5] and [11]. Example 2: Input: [1, 2, 3, 5].. 2020. 10. 6. [leetcode 494] Target Sum 문제: 주어진 모든 수 앞에 +나 -를 붙여서 계산한다. 계산값이 S와 동일한 경우를 카운트 Example 1: Input: nums is [1, 1, 1, 1, 1], S is 3. Output: 5 Explanation: -1+1+1+1+1 = 3 +1-1+1+1+1 = 3 +1+1-1+1+1 = 3 +1+1+1-1+1 = 3 +1+1+1+1-1 = 3 There are 5 ways to assign symbols to make the sum of nums be target 3. Constraints: The length of the given array is positive and will not exceed 20. The sum of elements in the given array will no.. 2020. 10. 6. [c++] accumulate 함수 - 배열 안에 모든 값을 더하는 함수 #include using namespace std int main(void){ vector v; //v 벡터 전체 합: 시작점, 마지막, 처음 시작 값 int sum = accumulate(v.begin(), v.end(), 0); //long long을 쓰려면 long long sum = accumulate(v.begin(), v.end(), 0LL); } 2020. 10. 6. [leetcode 647] Palindromic Substrings palindromic substring을 세는 문제 Example 1: Input: "abc" Output: 3 Explanation: Three palindromic strings: "a", "b", "c". Example 2: Input: "aaa" Output: 6 Explanation: Six palindromic strings: "a", "a", "a", "aa", "aa", "aaa". Note: The input string length won't exceed 1000. 다행히 문자열이 1000을 안넘어서 그런지 for문 돌려도 통과했다...하지만 몹시 느린 것이 사실 class Solution { public: int countSubstrings(string s) { int result =.. 2020. 10. 6. 이전 1 ··· 76 77 78 79 80 81 82 ··· 88 다음