- 博客(13)
- 收藏
- 关注
原创 NP-complete problems
8.3 STINGY SAT is the following problem: given a set of clauses (each a disjunction of literals) and an integer k, find a satisfying assignment in which at most k variables are true, if such an assign
2017-06-28 17:27:49 634
原创 算法设计与应用基础-第十三周&十四周
Range Sum Query - ImmutableGiven an integer array nums, find the sum of the elements between indicesi andj (i ≤j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2)
2017-05-25 16:24:23 161
原创 算法设计与应用基础-第十二周
Climbing Stairs 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 cli
2017-05-13 16:38:08 160
原创 算法设计与应用基础-第十一周
Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (i
2017-05-07 17:20:33 185
原创 算法设计与应用基础-第九周&第十周
n&(n-1)的妙用 (转)今天无聊拿起《编程之美》看了下,发现原来n&(n-1)还有很多妙用。原理:n与n-1的区别在于,对于n,从右向左数的第一个"1"开始一直到右,和n-1,完全相反n&(n-1)作用:将n的二进制表示中的最低位为1的改为0,先看一个简单的例子:n = 10100(二进制),则(n-1) = 10011 ==》n&(n-1) = 10000可以看到原本最
2017-04-25 16:21:16 165
原创 算法设计与应用基础-第八周
Find Mode in Binary Search TreeGiven a binary search tree (BST) with duplicates, find all themode(s) (the most frequently occurred element) in the given BST.Assume a BST is defined as foll
2017-04-15 16:43:02 229
原创 算法设计与应用基础-第七周
Intersection of Two Arrays IIGiven two arrays, write a function to compute their intersection.Example:Given nums1 =[1, 2, 2, 1],nums2 =[2, 2], return[2, 2].Note:Each element
2017-04-09 20:59:28 138
原创 算法设计与应用基础-第六周
Remove Duplicates from Sorted List Given a sorted linked list, delete all duplicates such that each element appear onlyonce.For example,Given 1->1->2, return1->2.Given 1->1->2->
2017-04-01 21:49:26 144
原创 算法设计与应用基础-第五周
Diameter of Binary TreeGiven a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of thelongest path between any two nodes in a tr
2017-03-26 11:06:18 223
原创 算法设计与应用基础-第四周
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares o
2017-03-19 13:23:22 209
原创 算法设计与应用基础-第三周
(1)Convert a Number to Hexadecimal Given an integer, write an algorithm to convert it to hexadecimal. For negative integer,two’s complement method is used.Note:All letters in he
2017-03-12 21:44:25 136
原创 算法设计与应用基础-第二周
(1)Add Strings Given two non-negative integers num1 andnum2 represented as string, return the sum ofnum1 andnum2.Note:The length of both num1 andnum2
2017-03-03 17:38:53 222
原创 算法设计与应用基础-第一周题目
(1) Search InsertPositionGiven a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assum
2017-02-25 20:28:54 183
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人