算法练习
XD_Senior
每天记录一点,每天进步一点。
展开
-
数据结构与算法 LeetCode编程练习--Search and Inserted in sorted array
Given 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 assume no duplicates in the array.Here原创 2015-12-19 21:19:17 · 468 阅读 · 0 评论 -
数据结构与算法 LeetCode编程练习--Search in Rotated array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its index原创 2015-12-20 00:05:38 · 484 阅读 · 0 评论 -
数据结构与算法 LeetCode编程练习--Search in Rotated array II
Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target is in原创 2015-12-20 17:25:15 · 439 阅读 · 0 评论 -
数据结构与算法 LeetCode编程练习--Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value原创 2015-12-22 00:09:34 · 499 阅读 · 0 评论 -
数据结构与算法 LeetCode编程练习--Contains Duplicate II
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and jis at most k.原创 2015-12-22 23:57:54 · 432 阅读 · 0 评论 -
数据结构与算法 LeetCode编程练习--counts Prime
Description:Count the number of prime numbers less than a non-negative number, n.Credits:Special thanks to @mithmatt for adding this problem and creating all test cases.Hint:Let's start原创 2015-12-23 22:03:23 · 657 阅读 · 0 评论