随笔分类 - LeetCode
算法很重要
摘要:前面面试华为状态不佳,然后就挂了,华为不聊技术只聊人生,莫名其妙地没有进二面,应该是水平不够吧。等了很久,蘑菇街给了笔试机会。 太久没有做笔试题了,突然来了一份笔试,想了很久,两道题都没有AC,还不知道有没有面试机会,暂且记录一下笔试题吧。都是宝贵的经验!都是常规题目! 重复元素的全排列 基本原理:
阅读全文
摘要:给定两个有序整数数组 nums1 和 nums2,将 nums2 合并到 nums1中,使得 num1 成为一个有序数组。 注意: 你可以假设 nums1有足够的空间(空间大小大于或等于m + n)来保存 nums2 中的元素。在 nums1 和 nums2 中初始化的元素的数量分别是 m 和 n。
阅读全文
摘要:给定一个排序链表,删除所有重复的元素使得每个元素只留下一个。 案例: 给定 ,返回 给定 ,返回
阅读全文
摘要:你正在爬楼梯。需要 n 步你才能到达顶部。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方式可以爬到楼顶呢? 注意:给定 n 将是一个正整数。 public int climbStairs(int n) { if (n
阅读全文
摘要:Implement int sqrt(int x). Compute and return the square root of x. x is guaranteed to be a non negative integer.
阅读全文
摘要:Given two binary strings, return their sum (also a binary string). For example, a = b = Return .
阅读全文
摘要:Implement pow(x, n). Example 1: public double myPow(double x, int n) { if (n
阅读全文
摘要:Given an array of strings, group anagrams together. For example, given: , Return:
阅读全文
摘要:You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Note: You have to rotate the image in place, which
阅读全文
摘要:Given a collection of distinct numbers, return all possible permutations. For example, [1,2,3] have the following permutations: public List permute(in
阅读全文
摘要:Given two non negative integers and represented as strings, return the product of and . Note: 1. The length of both num1 and num2 is =0 ; i ) { result
阅读全文
摘要:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each num
阅读全文
摘要:Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums
阅读全文
摘要:Given a non negative integer represented as a non empty array of digits, plus one to the integer. You may assume the integer do not contain any leadin
阅读全文
摘要:Determine if a Sudoku is valid, according to: Sudoku Puzzles The Rules. The Sudoku board could be partially filled, where empty cells are filled with
阅读全文
摘要:Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime complexi
阅读全文
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You a
阅读全文
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib
阅读全文
摘要:Given a string s consists of upper/lower case alphabets and empty space characters ' ', return the length of last word in the string. If the last word
阅读全文
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [ 2,1, 3,4, 1,2,
阅读全文
浙公网安备 33010602011771号