随笔分类 - java&LeetCode
摘要:110. Balanced Binary Tree Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a bin
        阅读全文
            
摘要:415. Add Strings Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: java代码:
        阅读全文
            
摘要:401. Binary Watch java代码:
        阅读全文
            
摘要:189. Rotate Array Rotate 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
        阅读全文
            
摘要:100. Same Tree Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structura
        阅读全文
            
摘要:404. Sum of Left Leaves Find the sum of all left leaves in a given binary tree. Example:
        阅读全文
            
摘要:14. Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. 要求一个字符串数组里面最长公共前缀字符串(数组里面所有字符串) 一开始求成
        阅读全文
            
摘要:476. Number Complement Example 1: Example 2: 求一个数的补码。 另一种解法: 举个例子:100110, 它的补码是 011001, 和是 111111. 所以我们先求和num的二进制长度相同全为一的数,然后做减法
        阅读全文
            
摘要:344. Reverse String Write a function that takes a string as input and returns the string reversed. 反转string字符串 java代码: 第二种解法,更加快速 java代码:
        阅读全文
            
摘要:461. Hamming Distance 求两个数之间的汉明距离,两个等长字符串之间的汉明距离是两个字符串对应位置的不同字符的个数。换句话说,它就是将一个字符串变换成另外一个字符串所需要替换的字符个数。这里将书转化为二进制然后比较相同位置不同的数有几个。 java代码: 第二种方法,x,y两个数可
        阅读全文
            
摘要:257. Binary Tree Paths Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: All root-to-leaf paths are:
        阅读全文
            
摘要:27. Remove Element 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 
        阅读全文
            
摘要:441. Arranging Coins You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, 
        阅读全文
            
摘要:20. Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brack
        阅读全文
            
摘要:1. Two Sum Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input wo
        阅读全文
            
摘要:7. Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 此题题意为反转一个整数个各个数字,比如123,翻转后为321 java代码: 但
        阅读全文
            
摘要:13. Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 给定一个罗马数字s,( I<=s<=MMM
        阅读全文
            
摘要:Excel Sheet Column Number Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding colu
        阅读全文
            
摘要:Fizz Buzz Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of
        阅读全文
            
摘要:Add Binary Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 求两个二进制数的和 java代码:
        阅读全文
            
                    
                
浙公网安备 33010602011771号