标签: leetcode

记录点滴,修炼自己。
0

leetcode [#283]

题目 Given 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. Example:given nums = [0, 1, 0, 3, 12], after calling your func

0

leetcode [#278]

题目 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 check. Since each version is developed based on

0

leetcode [#28]

题目 Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 解决方案123456789101112131415161718192021222324252627282930public class

0

leetcode [#263]

题目 Write 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. ExampleFor example, 6, 8 are ugly while 14 is not ugl

0

leetcode [#268]

题目 Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array. For example: Given nums = [0, 1, 3] return 2. NoteYour algorithm should run in l

0

leetcode [#26]

题目 Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place wit

0

leetcode [#27]

题目 Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. Th

0

leetcode [#258]

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

0

leetcode [#242]

题目 Given two strings s and t, write a function to determine if t is an anagram of s. Example:s = “anagram”, t = “nagaram”, return true.s = “rat”, t = “car”, return false. Note:You may assume the stri

0

leetcode [#24]

题目 Given a linked list, swap every two adjacent nodes and return its head. Example:Given 1->2->3->4, you should return the list as 2->1->4->3. Note:Your algorithm should use only co

0

leetcode [#237]

题目 Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node

0

leetcode [#237]

题目 Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it without division and in O

0

leetcode [#234]

题目 Given a singly linked list, determine if it is a palindrome. 解决方案1234567891011121314151617181920212223242526272829303132/** * Definition for singly-linked list. * public class ListNode { *

0

leetcode [#232]

题目 Implement 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() – Get the front element. empt

0

leetcode [#231]

题目 Given an integer, write a function to determine if it is a power of two. 解决方案1234567891011public class Solution { public boolean isPowerOfTwo(int n) { if(n < 0) return fal

0

leetcode [#219]

题目 Given 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 difference between i and j is at most k. 解决方

0

leetcode [#226]

题目 解决方案1234567891011121314151617181920212223/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x)

0

leetcode [#225]

题目 Implement 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 element. empty() – Return whe

0

leetcode [#226]

题目 解决方案12345678910111213public class Solution { public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) { int s1 = (C - A) * (D - B); int s2 = (G

0

leetcode [#22]

题目 Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: [ “((()))”, “(()())”, “(())()”, “()(())”,