原创 華爲機試刷題

服務器廣播 題目:服務器連接方式包括直接相連,間接連接。 A 和 B 直接連接, B 和 c 直接連接,則 A 和 c 間接連接。直接連接和間接連接都可以發送廣播。 給出一個 N * N 數組,代表 N 個服務器, mat

原创 Leetcode 343. Integer Break

Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of tho

原创 字符串匹配的Boyer-Moore算法

轉載自:http://www.ruanyifeng.com/blog/2013/05/boyer-moore_string_search_algorithm.html 上一篇文章,我介紹了KMP算法。 但是,它並不是效率最高的算

原创 Leetcode 219. 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 s

原创 Leetcode 125. Valid Palindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For e

原创 Leetcode 62. Unique Paths

A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only

原创 Leetcode 347. Top K Frequent Elements

Given a non-empty array of integers, return the k most frequent elements. For example, Given [1,1,1,2,2,3] and k =

原创 Leetcode 67. Add Binary

Given two binary strings, return their sum (also a binary string). For example, a = “11” b = “1” Return “100”. 按

原创 Leetcode 190. Reverse Bits

Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 00000

原创 Leetcode 28. Implement strStr()

Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of

原创 Leetcode 365. Water and Jug Problem

You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You n

原创 Leetcode 318. Maximum Product of Word Length

Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not

原创 Leetcode 378. Kth Smallest Element in a Sorted Matrix

Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in

原创 Leetcode 230. Kth Smallest Element in a BST

Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume

原创 路燈最小發光距離

題目描述 V先生有一天工作到很晚,回家的時候要穿過一條長l的筆直的街道,這條街道上有n個路燈。假設這條街起點爲0,終點爲l,第i個路燈座標爲ai。路燈發光能力以正數d來衡量,其中d表示路燈能夠照亮的街道上的點與路燈的最遠距離,所有路燈發