본문 바로가기

분류 전체보기

(11)
Leetcode #78 Subse This is a problem that finding all possible subsets (power set) from givien integer array. Input: nums = [1,2,3] Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] Each element of the array can be add to subset or not which is 2 number of cases each. Therefore total number of cases that can be made with 3 elements of array is 8 (2^3). First level branches indicates that either adding 1 or not to..
Leetcode #153 Find Minimum in Rotated Sorted Array This Problem we are trying to find mininum value from Rotated Sorted Array. For example, if there is an array [0, 1, 2, 3, 4, 5, 6, 7] that is already sorted it gets rotated by random number n. Case A If the array is [4, 5, 6, 7, 0, 1, 2, 3] it rotated 4 times. What we need are mid point, most left point, and most right point. 1. In this case mid point become 7 and we knows that the mid point is..
Leetcode #704 Binary Search Binary Search is a one of the efficient search algorithm that uses a lot for various reasons. It is super simple to demonstrate and how it works. First lets say, we have size of 8 sorted array [0, 1, 3, 7, 9, 14, 16, 19] and the target number is 16 and we are trying to find the index of the target. 1. We set most left and most right and then we set the mid point which is 9 in this case. 2. If th..
Features of Object Oriented Programming - Abstraction Absctraction is one of the most strongest and powerful feature of Object Oriented Programming. It can bind common properties together and manage them in same category. For example, when there is a Lion, Tiger, Leopard, Whale, Fish, Seatutle. We can categorize by them as animal. However, we can categorize by them as a mammal and non mammal, Cat family and non cat family or land aniaml or sea anim..
Object Oriented Programming What is "Object" Object is everything that we are usuing in daily life. If you ever took any object oriented object program, you will know the "Car" example. What compose a car? Accelerator, break, steer wheel, doors, tires etc. These parts interact each other and let the car moves. In Programming, Object is instance (exist in real : actual car parts) which is created by Classes. Therefore, obje..
Leetcode #125 Valid Palindrome A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. class Solution(object): def isPalindrome(self, s): """ :type s: str :rtype: bool """ // Change input string to lower case s = s.lower() target = "" for el in s: // trim..
Leetcode #243 Valid Anagram An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. For example, rat and tar, a gentleman and elegant man are anagram. I used brute force way to solve this problem class Solution(object): def isAnagram(self, s, t): """ :type s: str :type t: str :rtype: bool """ if len(s) != len(t): return False // ..
Chapter 2 Array Array is one of the most basic Data Structure. Data Structure is logical or physical relationshop between data. Or more simply, Data structure is way to save data in computer to use it effectively. Array is a compliation of element (that holds data) in linear shape. For example, int a[6]; To call thrid element in this Array.. we can use index. a[2] it will return 10 as an element. In C language ..