摘要: Given a sorted array, two integers k and x, find the k closest elements to x in the array. The result should also be sorted in ascending order. If the 阅读全文
posted @ 2018-12-04 09:25 fatttcat 阅读(177) 评论(0) 推荐(0)
摘要: You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c 阅读全文
posted @ 2018-12-04 05:13 fatttcat 阅读(92) 评论(0) 推荐(0)
摘要: Suppose an array sorted in ascending order 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]). F 阅读全文
posted @ 2018-12-04 04:59 fatttcat 阅读(112) 评论(0) 推荐(0)
摘要: Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endp 阅读全文
posted @ 2018-12-04 02:57 fatttcat 阅读(110) 评论(0) 推荐(0)
摘要: Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrenc 阅读全文
posted @ 2018-12-03 18:04 fatttcat 阅读(149) 评论(0) 推荐(0)
摘要: Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the or 阅读全文
posted @ 2018-12-03 17:25 fatttcat 阅读(114) 评论(0) 推荐(0)
摘要: Comparing Methods a.compareTo(b); //按字典顺序比较两个字符串,返回0: a=b, 返回正数: a > b, 返回负数: a < b Sorting Methods Arrays.sort(); //字母序优先于长度Collections.sort(); Custo 阅读全文
posted @ 2018-12-03 15:04 fatttcat 阅读(209) 评论(0) 推荐(0)
摘要: Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) Yo 阅读全文
posted @ 2018-12-03 14:55 fatttcat 阅读(138) 评论(0) 推荐(0)
摘要: Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2018-12-03 14:12 fatttcat 阅读(123) 评论(0) 推荐(0)
摘要: Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra spa 阅读全文
posted @ 2018-12-03 13:45 fatttcat 阅读(138) 评论(0) 推荐(0)