標籤:: Go

0

Move Zeroes

Move ZeroesGiven an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. For example:1Given nums = [0, 1, 0, 3, 12], after call

0

Missing Number

Missing NumberGiven an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array. For example:1Given nums = [0, 1, 3] return 2. Note: Your algorithm sh

0

Ugly Number

Ugly NumberWrite a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ug

0

Add Digits

Add DigitsGiven a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example:1Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has onl

0

Binary Tree Paths

Binary Tree PathsGiven a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 12345 1 / \2 3 \ 5 All root-to-leaf paths are: 1["1->2->5",

0

Palindrome Linked List

Palindrome Linked ListGiven two strings s and t, write a function to determine if t is an anagram of s. For example:12s = "anagram", t = "nagaram", return true.s = "rat"

0

Palindrome Linked List

Palindrome Linked ListGiven a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? 提示 解題應用 LinkedList Pointer Default:12345678910/**

0

Implement Queue using Stacks

Implement Queue using StacksImplement the following operations of a queue using stacks. push(x) – Push element x to the back of queue. pop() – Removes the element from in front of queue. peek() – Ge

0

Power of Two

Power of TwoGiven an integer, write a function to determine if it is a power of two. 提示 解題應用 Math 規律觀查 BitManipulation AND Default:123func isPowerOfTwo(n int) bool { } 解答思路:一

0

Invert Binary Tree

Invert Binary TreeInvert a binary tree. 12345 4 / \ 2 7 / \ / \1 3 6 9 to 12345 4 / \ 7 2 / \ / \9 6 3 1 提示 解題應用 Tree 樹的遍歷方式 Default:1234567891011/** *

0

Implement Stack using Queues

Implement Stack using QueuesImplement the following operations of a stack using queues. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the top elem

0

Contains Duplicate II

Contains Duplicate IIGiven 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 absolute difference between

0

Contains Duplicate

Contains DuplicateGiven an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false

0

Reverse Linked List

Reverse Linked ListReverse a singly linked list. 提示 解題應用 LinkedList Pointer Default:12345678910/** * Definition for singly-linked list. * type ListNode struct { * Val int * Nex

0

Isomorphic Strings

Isomorphic StringsGiven 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 occurrences of a character must be repla

0

Count Primes

Count PrimesCount the number of prime numbers less than a non-negative number, n. 提示 解題應用 HashTable Array Math 規律觀查 Default:123func countPrimes(n int) int {} 解答思路:非常典型的空間換取時間,因為

0

Remove Linked List Elements

Remove Linked List ElementsRemove all elements from a linked list of integers that have value val. Example:12Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2

0

Happy Number

Happy NumberWrite 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 t

0

House Robber

House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that a

0

Rotate Array

Rotate ArrayRotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Note: Try to come up as many solutions a

0

Factorial Trailing Zeroes

Factorial Trailing ZeroesGiven an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. 提示 解題應用 Math 觀查規律 Default:123func trai

0

Excel Sheet Column Number

Excel Sheet Column NumberRelated to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example:1234567A -> 1B -> 2C