월간 보관물: 2017 11월

[LeetCode] 70 – Climbing Stairs

problem: https://leetcode.com/problems/climbing-stairs/description/ You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a positive integer. … 계속 읽기

카테고리: 기초 개발실력 다지기, ICT, LeetCode | 태그: , , , | 댓글 남기기

[LeetCode] 125 – Valid Palindrome

problem: https://leetcode.com/problems/valid-palindrome/description/ Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, “A man, a plan, a canal: Panama” is a palindrome. “race a car” is not a palindrome. Note: Have you consider that the string might … 계속 읽기

카테고리: 기초 개발실력 다지기, ICT, LeetCode | 태그: , , , | 댓글 남기기

[BAEKJOON] 팰린드롬인지 확인하기

problem: https://www.acmicpc.net/problem/10988 문제 알파벳 소문자로만 이루어진 단어가 주어진다. 이 때, 이 단어가 팰린드롬인지 아닌지 확인하는 프로그램을 작성하시오. 팰린드롬이란 앞으로 읽을 때와 거꾸로 읽을 때 똑같은 단어를 말한다. level, noon은 팰린드롬이고, baekjoon, online, judge는 팰린드롬이 아니다. 입력 첫째 줄에 단어가 주어진다. 단어의 … 계속 읽기

카테고리: 기초 개발실력 다지기 | 태그: , | 댓글 남기기

[LeetCode] 172 – Factorial Trailing Zeroes

problem: https://leetcode.com/problems/factorial-trailing-zeroes/description/ Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. Credits: Special thanks to @ts for adding this problem and creating all test cases. Code(C++) class Solution { public: int trailingZeroes(int n) { … 계속 읽기

카테고리: 기초 개발실력 다지기, ICT, LeetCode | 태그: , , , | 댓글 남기기

[LeetCode] 119 – Pascal’s Triangle II

problem: https://leetcode.com/problems/pascals-triangle-ii/description/ Given an index k, return the kth row of the Pascal’s triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space? Code(C++) class Solution { public: vector<int> getRow(int rowIndex) { vector<int> ret(rowIndex+1, 0); ret[0] = … 계속 읽기

카테고리: 기초 개발실력 다지기, ICT, LeetCode | 태그: , , , | 댓글 남기기

[LeetCode] 53 – Maximum Subarray

problem: https://leetcode.com/problems/maximum-subarray/description/ Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,1,-5,4], the contiguous subarray [4,-1,2,1] has the largest sum = 6. Code(C++) class Solution { public: int maxSubArray(vector<int>& nums) { int … 계속 읽기

카테고리: 기초 개발실력 다지기, ICT, LeetCode | 태그: , , , | 댓글 남기기

[LeetCode] 20 – Valid Parentheses

problem: https://leetcode.com/problems/valid-parentheses/description/ Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid. The brackets must close in the correct order, “()” and “()[]{}” are all valid but “(]” and “([)]” are not. Code(C++) class Solution { public: bool isValid(string s) { int sSize = s.size(); … 계속 읽기

카테고리: 기초 개발실력 다지기, ICT, LeetCode | 태그: , , , | 댓글 남기기

[LeetCode] 14 – Longest Common Prefix

problem: https://leetcode.com/problems/longest-common-prefix/description/ Write a function to find the longest common prefix string amongst an array of strings. Code(C++) class Solution { public: string longestCommonPrefix(vector<string>& strs) { if (strs.empty()) return “”; int strsSize = strs.size(); string ret = strs[0]; if (strsSize == … 계속 읽기

카테고리: 기초 개발실력 다지기, ICT, LeetCode | 태그: , , , | 댓글 남기기

[LeetCode] 9 – Palindrome Number

problem: https://leetcode.com/problems/palindrome-number/description/ Determine whether an integer is a palindrome. Do this without extra space. Code(C++) class Solution { public: bool isPalindrome(int x) { if (x < 0 || x != 0 && x % 10 == 0) return false; int sum … 계속 읽기

카테고리: 기초 개발실력 다지기, ICT, LeetCode | 태그: , , , | 댓글 남기기

[LeetCode] 5 – Longest Palindromic Substring

problem: https://leetcode.com/problems/longest-palindromic-substring/ Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example: Input: “babad” Output: “bab” Note: “aba” is also a valid answer. Example: Input: “cbbd” Output: “bb” accepted Code(C++) class Solution … 계속 읽기

카테고리: 기초 개발실력 다지기, ICT, LeetCode | 태그: , , , | 댓글 남기기