随笔分类 -  Level 1

摘要:Write a function that add two numbers A and B. You should not use + or any arithmetic operators. 分析: 典型的Bit Operation. 阅读全文
posted @ 2016-07-06 02:21 北叶青藤 阅读(192) 评论(0) 推荐(0)
摘要:Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Find all the keys of tree in range k1 to k2. i.e. print all x s 阅读全文
posted @ 2016-07-05 06:09 北叶青藤 阅读(201) 评论(0) 推荐(0)
摘要:For a given sorted array (ascending order) and a target number, find the first index of this number in O(log n) time complexity. If the target number 阅读全文
posted @ 2016-07-04 01:22 北叶青藤 阅读(245) 评论(0) 推荐(0)
摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文
posted @ 2016-07-03 08:03 北叶青藤 阅读(171) 评论(0) 推荐(0)
摘要:Merge two sorted (ascending) linked lists and return it as a new sorted list. The new sorted list should be made by splicing together the nodes of the 阅读全文
posted @ 2016-07-03 04:22 北叶青藤 阅读(140) 评论(0) 推荐(0)
摘要:Write a program to find the node at which the intersection of two singly linked lists begins. Notice If the two linked lists have no intersection at a 阅读全文
posted @ 2016-07-03 02:12 北叶青藤 阅读(156) 评论(0) 推荐(0)
摘要:Find K-th largest element in an array. Notice You can swap elements in the array Example In array [9,3,2,4,8], the 3rd largest element is 4. In array  阅读全文
posted @ 2016-07-02 12:03 北叶青藤 阅读(164) 评论(0) 推荐(0)
摘要:Remove all elements from a linked list of integers that have value val. Example Given 1->2->3->3->4->5->3, val = 3, you should return the list as 1->2 阅读全文
posted @ 2016-07-02 11:24 北叶青藤 阅读(183) 评论(0) 推荐(0)
摘要:Merge two given sorted integer array A and B into a new sorted integer array. Merge two given sorted integer array A and B into a new sorted integer a 阅读全文
posted @ 2016-07-02 09:59 北叶青藤 阅读(217) 评论(0) 推荐(0)
摘要:Given a rotated sorted array, recover it to sorted array in-place. Given a rotated sorted array, recover it to sorted array in-place. Given a rotated  阅读全文
posted @ 2016-07-02 09:52 北叶青藤 阅读(176) 评论(0) 推荐(0)
摘要:Given two sorted integer arrays A and B, merge B into A as one sorted array. Notice You may assume that A has enough space (size that is greater or eq 阅读全文
posted @ 2016-07-01 10:41 北叶青藤 阅读(146) 评论(0) 推荐(0)
摘要:Remove Duplicates from Sorted Array I Given a sorted array, remove the duplicates in place such that each element appear only once and return the new 阅读全文
posted @ 2016-07-01 08:49 北叶青藤 阅读(156) 评论(0) 推荐(0)
摘要:Given a sorted (increasing order) array, Convert it to create a binary tree with minimal height. Example Given [1,2,3,4,5,6,7], return 4 / \ 2 6 / \ / 阅读全文
posted @ 2016-07-01 05:31 北叶青藤 阅读(230) 评论(0) 推荐(0)
摘要:Cosine similarity is a measure of similarity between two vectors of an inner product space that measures the cosine of the angle between them. The cos 阅读全文
posted @ 2016-07-01 03:11 北叶青藤 阅读(532) 评论(0) 推荐(0)
摘要:Intersection of Two Arrays Given two arrays, write a function to compute their intersection. Example Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], retur 阅读全文
posted @ 2016-06-30 12:50 北叶青藤 阅读(222) 评论(0) 推荐(0)
摘要:Question: 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 阅读全文
posted @ 2015-06-24 02:44 北叶青藤 阅读(148) 评论(0) 推荐(0)
摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the 阅读全文
posted @ 2015-06-24 01:00 北叶青藤
摘要:Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. The key part is i <= haystack.length() - nee 阅读全文
posted @ 2015-01-10 08:39 北叶青藤 阅读(123) 评论(0) 推荐(0)
摘要:Write a function to find the longest common prefix string amongst an array of strings. For instance: ["ab", "bc"] returns ""; ["a", "ab"] re 阅读全文
posted @ 2015-01-06 09:32 北叶青藤 阅读(153) 评论(0) 推荐(0)
摘要:把字符串前面的若干个字符移动到字符串的尾部。如把字符串abcdef前2位字符移到后面得到字符串cdefab。要求时间对长度为n的字符串操作的复杂度为O(n),辅助内存为O(1)。 分析:如果不考虑时间和空间复杂度的限制,最简单的方法莫过于把这道题看成是把字符串分成前后两部分,把原字符串后半部分拷贝到 阅读全文
posted @ 2015-01-06 09:28 北叶青藤 阅读(238) 评论(0) 推荐(0)