
LeetCode
xh15
本人平凡俗世一女子,略有些优点,然不足一提;略有些缺点,却也无伤大雅!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[LeetCode-349] Intersection of Two Arrays(java)
Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element in the result must be unique. The result can b原创 2016-10-08 20:19:41 · 593 阅读 · 0 评论 -
[LeetCode-389]Find the Difference
Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at a random position. Find the letter that was added原创 2016-10-02 00:16:47 · 378 阅读 · 0 评论 -
[LeetCode-409]Longest Palindrome(java)
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. This is case sensitive, for example “Aa” is not consid原创 2016-10-03 01:31:27 · 1842 阅读 · 1 评论 -
[LeetCode-226]Invert Binary Tree(java)
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 题意: 翻转二叉树,属于二叉树基本操作。 不过关于这道题是关于Max Howell大神的一次求职,其来自于Twitter的转播“原创 2016-10-04 15:59:48 · 487 阅读 · 0 评论 -
[LeetCode-283]Move Zeroes(java)
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. For example, given nums = [0, 1, 0, 3, 12], after calling your fun原创 2016-10-04 16:49:46 · 485 阅读 · 0 评论 -
[LeetCode-404]Sum of Left Leaves(java)
Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 15 respectively.原创 2016-10-05 12:52:06 · 1216 阅读 · 0 评论 -
[LeetCode-383]Ransom Note(java)
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be construc原创 2016-10-06 15:07:12 · 635 阅读 · 0 评论 -
[LeetCode-237]Delete Node in a Linked List(java)
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 with value 3,原创 2016-10-07 12:57:32 · 501 阅读 · 0 评论 -
java排列组合问题汇总【经典】
面试或笔试中,多次遇到以下4个关于排雷组合的手撕算法,这里做个笔记,方法日后查阅: 1. 无重复元素的数组,求全排列; 2. 有重复元素的数组,求全排列; 3. 无重复元素的数组,求组合【子集】; 4. 有重复元素的数组,求组合; 以上四类题,可以用统一的模板实现,如下所示:/* *【组合&&排列】 *把一个数组里的数组合全部列出,比如1和2列出来为1,2,12,21. *这原创 2017-09-18 03:49:44 · 3451 阅读 · 0 评论 -
[LeetCode-104]Maximum Depth of Binary Tree (java)
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 farthest leaf node. 题意:求一个二叉树的深度(即从根节点到最远叶子节点的距离) 分析:学过数据结原创 2016-10-01 00:54:58 · 413 阅读 · 0 评论 -
[LeetCode-258]Add Digits(java)
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 digi原创 2016-09-30 00:58:24 · 468 阅读 · 0 评论 -
[LeetCode-100]Same Tree(java)
Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 题意: 给出两颗二叉树,判断原创 2016-10-08 20:48:41 · 795 阅读 · 0 评论 -
[LeetCode-171]Excel Sheet Column Number(java)
Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 … Z -原创 2016-10-08 21:14:02 · 1092 阅读 · 0 评论 -
[LeetCode-345]Reverse Vowels of a String(java)
Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Given s = “hello”, return “holle”. Example 2: Given s = “leetcode”, return “leotcede”. Note: The原创 2016-10-10 11:08:15 · 537 阅读 · 0 评论 -
[LeetCode-2]Add Two Numbers(java)
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link原创 2016-09-25 16:44:51 · 361 阅读 · 0 评论 -
[LeetCode-371]Sum of Two Integers(C)
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return 3.分析:首先不能使用加减运算,那只有位运算了;17+5=22的过程,先不考虑进位,即17+05=原创 2016-09-25 18:28:03 · 331 阅读 · 0 评论 -
[LeetCode-344]Reverse String(c++)
Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".原创 2016-09-27 17:45:21 · 533 阅读 · 0 评论 -
[LeetCode-292]Nim Game(c++)
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原创 2016-09-27 20:58:53 · 508 阅读 · 0 评论 -
[LeetCode-136]Single Number(java)
Given an array of integers, every element appears twice except for one. Find that single one. Note: our algorithm should have a linear runtime complexity. Could you implement it without using extra原创 2016-09-29 01:03:43 · 507 阅读 · 0 评论 -
java排列组合变形汇总【经典】
首先,感谢原博主的文章http://blog.youkuaiyun.com/javyzheng/article/details/41041667题目: 把一个数组里的数的组合全部列出,比如1和2列来为1,2,12,21. 分析: 这道题有多种扩展, 1,没有重复元素的数的组合(包括子集的全排列); 2,有重复元素的数的组合; 3,没有重复元素的数的全排列; 4,有重复元素的数的全排列。1,没有重复转载 2017-09-18 05:03:29 · 2849 阅读 · 0 评论