随笔分类 - Level 1
摘要:Write a function that add two numbers A and B. You should not use + or any arithmetic operators. 分析: 典型的Bit Operation.
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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 / \ /
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要:Write a function to find the longest common prefix string amongst an array of strings. For instance: ["ab", "bc"] returns ""; ["a", "ab"] re
阅读全文
摘要:把字符串前面的若干个字符移动到字符串的尾部。如把字符串abcdef前2位字符移到后面得到字符串cdefab。要求时间对长度为n的字符串操作的复杂度为O(n),辅助内存为O(1)。 分析:如果不考虑时间和空间复杂度的限制,最简单的方法莫过于把这道题看成是把字符串分成前后两部分,把原字符串后半部分拷贝到
阅读全文

浙公网安备 33010602011771号