目前分類:未分類文章 (31)

瀏覽方式: 標題列表 簡短摘要

Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.

An input string is valid if:

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

Write a function to find the longest common prefix string amonst an array of strings.

If there is no common prefix, return an empty string "".

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

題目

  Reverse a singly linked list

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

題目

  Write a function to delete a node (except the tail) in a singly linked list, given  only access to that node.

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

Question 

  Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

Question

  Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

題目

  Given an array of integers, 1 <= a[i] <= n (n = size of array), some elements appear twice and others appear once. Find all the elements that appear twice in this array.

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

題目

  For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page's area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements:

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

題目

  Given two strings s and t which consist of only lowercase letters.

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

題目

  Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is increasing a selected element by 1 or decrementing a selected element by 1.

Davis 發表在 痞客邦 留言(0) 人氣()

Given a binary tree, find its maximum depth.

The maximum depth is the number of nodes along the longest path from the root node down to the fartheast leaf node.

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.

題意

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

Write an algorithm to determine if a number is "happy".

A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

Given an integer, write a function to determine if it is a power of two.

題意

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

Given an integer, write a function to determine if it is a power of three.

題意

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two's complement method is used.

題意

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.

題意

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

Given an array of integers, every element appears twice except for one. Find the single one.

Note:

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the winner. You will take the first turn to remove the stones.

Both of you are very clever and have optimal stratgies for the game. Write a function to determine whether you can win the game given the number of stones in the heap.

文章標籤

Davis 發表在 痞客邦 留言(0) 人氣()

Given an array of integers where 1 <= a[i] <= n (n=size of array), some elements appear twice and others appear once.

Find all the elements of [1, n] inclusive that do not appear in this array.

Davis 發表在 痞客邦 留言(0) 人氣()

1 2