`
文章列表
Majority Number I Given an array of integers, the majority number is the number that occurs more than half of the size of the array. Find it.   Example Given [1, 1, 1, 1, 2, 2, 2], return 1  Challenge O(n) time and O(1) extra space  public int ma
Given an expression string array, return the final result of this expression. Hint: Shunting-yard algorithm Example For the expression 2*6-(23+7)/(1+2), input is [ "2", "*", "6", "-", "(", "23", "+", "7", &q ...
Given an expression string array, return the Reverse Polish notation of this expression. (remove the parentheses) Aka, convert infix notation to postfix notation.   Example For the expression [3 - 4 + 5] (which denote by ["3", "-", "4", "+", "5" ...
Given an expression string array, return the Polish notation of this expression. (remove the parentheses) Aka, convert infix notation to prefix notation.  Example For the expression [(5 − 6) * 7] (which represented by["(", "5", "−", "6", ")" ...
Equilibrium index of an array is an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes. For example, in an arrya A: A[0] = -7, A[1] = 1, A[2] = 5, A[3] = 2, A[4] = -4, A[5] = 3, A[6]=0 3 is an equilibrium index, because:A[0] + A[1] + A[2] = A[4] ...
Google: Compute the h-index of a list of papers, given their citation count. Can you do it in linear time? How about a distributed algorithm for the task?   Facebook: Given: for every paper authored, there is a citation count vector. The h-index is a measure of researcher importance. h-index: T ...
将博客搬至CSDN http://blog.csdn.net/yuanhisn
Problem statement You are given N subsequences(not necessarily contiguous) of a string. Find the shortest possible string which has distinct lower case letters, with the given subsequences. The solution is guaranteed to exist.    Input   The first line has the value of N, followed by N lines co ...
Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation. For example: Given "aacecaaa", return "aaacecaaa". Given "abcd", return &q ...
Note: This is an extension of House Robber. After robbing those houses on that street, the thief has found himself a new place for his thievery so that he will not get too much attention. This time, all houses at this place are arranged in a circle. That means the first house is the neighbor of the ...
There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1] Given the total number of courses and a list of prerequisite pairs, return the ordering o ...
Find the kth largest element in an unsorted array. For example,Given [3,2,1,5,6,4] and k = 2, return 5. Note: You may assume k is always valid, 1 ≤ k ≤ array's length. public int findKthLargest(int[] nums, int k) { return findKthLargest(nums, 0, nums.length-1, k-1); } private int findKth ...
Design a data structure that supports the following two operations: void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter. For example: addWord("bad") ad ...
Contents 1 Final update in 2-3 years: 2 Tasks 2.1 Online Practice 2.2 Side Projects!
Given two unsorted arrays that represent two sets (elements in every array are distinct), find union and intersection of two arrays. For example, if the input arrays are:arr1[] = {7, 1, 5, 2, 3, 6}arr2[] = {3, 8, 6, 20, 7}Then your program should print Union as {1, 2, 3, 5, 6, 7, 8, 20} and Interse ...
Global site tag (gtag.js) - Google Analytics