随笔分类 - Algorithms
摘要:Saying that we have some icons and a target sum, for example 16. How to choose which and how many icons to include to reach the target but minize the
阅读全文
摘要:A serial of number, you cannot add siblings number together. To calcaulate what is the max sum value. Thinking: 1. Weather I should add current number
阅读全文
摘要:Fibonacci sequence: The most well-known approach is memoization. Advantage is fast, but space complexity is big. O(N). Bottom-up: 1 : Bottom-up dynami
阅读全文
摘要:In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue. For now, suppose you are a domin
阅读全文
摘要:Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n]
阅读全文
摘要:Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: 4 / \ 7 2 / \ / \ 9 6 3 1 /** * Definition for a binary tree node. * function
阅读全文
摘要:Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: Input: [1,2,3,4,5,6,7] and k = 3 Output: [5,6,7,1,2,3,4]
阅读全文
摘要:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and num
阅读全文
摘要:Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true /** * Defi
阅读全文
只有注册用户登录后才能阅读该文。
只有注册用户登录后才能阅读该文。
只有注册用户登录后才能阅读该文。
只有注册用户登录后才能阅读该文。
只有注册用户登录后才能阅读该文。
只有注册用户登录后才能阅读该文。
只有注册用户登录后才能阅读该文。
摘要:A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128
阅读全文
摘要:Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are n
阅读全文
只有注册用户登录后才能阅读该文。
摘要:Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the bi
阅读全文