- 博客(41)
- 资源 (1)
- 收藏
- 关注
原创 LeetCode 175 -Combine Two Tables ( MYSQL )
Table: Person+-------------+---------+| Column Name | Type |+-------------+---------+| PersonId | int || FirstName | varchar || LastName | varchar |+-------------+---------+Per
2016-04-16 10:45:07 1176 3
原创 LeetCode 182 -Duplicate Emails ( MYSQL )
Write a SQL query to find all duplicate emails in a table named Person.+----+---------+| Id | Email |+----+---------+| 1 | a@b.com || 2 | c@d.com || 3 | a@b.com |+----+---------+For
2016-04-16 10:21:47 604
原创 LeetCode 181 -Employees Earning More Than Their Managers ( MYSQL )
The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.+----+-------+--------+-----------+| Id | Name | Salary |
2016-04-16 09:59:02 717
原创 LeetCode 83 -Remove Duplicates from Sorted List ( JAVA )
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3./** * Definition f
2016-04-15 16:57:35 622
原创 LeetCode 22 -Generate Parentheses ( JAVA )
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:"((()))", "(()())", "(())()", "()(())", "()()
2016-04-15 16:18:56 689
原创 LeetCode 141 -Linked List Cycle ( JAVA )
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list. * class ListNode { * int val
2016-04-14 13:45:44 783
原创 LeetCode 35 -Search Insert Position ( JAVA )
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.
2016-04-12 14:30:07 927
原创 LeetCode 338 -Counting Bits ( JAVA )
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5
2016-04-11 17:50:48 1227
原创 LeetCode 230 -Kth Smallest Element in a BST ( JAVA )
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements.Follow up:What if the
2016-04-11 17:33:01 946
原创 LeetCode 137 -Single Number II ( JAVA )
Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without u
2016-04-11 15:54:35 850
原创 LeetCode 328 -Odd Even Linked List ( JAVA )
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in
2016-04-11 15:41:01 647
原创 LeetCode 191 -Number of 1 Bits ( JAVA )
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 000000
2016-04-11 12:50:50 1385 2
原创 LeetCode 235 -Lowest Common Ancestor of a Binary Search Tree ( JAVA )
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined betw
2016-04-11 11:54:10 569
原创 LeetCode 287 -Find the Duplicate Number ( JAVA )
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number,
2016-04-11 11:05:09 878
原创 LeetCode 12 -Integer to Roman ( JAVA )
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.public class Solution { public String intToRoman(int num) { String s
2016-04-10 20:20:20 1036
原创 LeetCode 13 -Roman to Integer ( JAVA )
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.public class Solution { public int romanToInt(String s) { HashMap ma
2016-04-10 19:45:23 774
原创 LeetCode 206 -Reverse Linked List 单链表翻转问题 ( JAVA )
Reverse a singly linked list.click to show more hints.Subscribeto see which companies asked this question/** * Definition for singly-linked list. * public class ListNode { * int v...
2016-04-10 17:15:03 593
原创 LeetCode 154 -Binary Tree Postorder Traversal ( JAVA )
Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1]./** * Definiti
2016-04-10 14:44:52 492
原创 LeetCode 94 -Binary Tree Inorder Traversal ( JAVA )
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2]./** * Definition
2016-04-10 14:23:50 428
原创 LeetCode 318 -Maximum Product of Word Lengths ( JAVA )
Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case le
2016-04-10 14:16:08 654
原创 LeetCode 144 -Binary Tree Preorder Traversal ( JAVA )
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3]./** * Definitio
2016-04-10 12:24:51 385
原创 LeetCode 268 -Missing Number ( JAVA )
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.Note:Your algorithm sho
2016-04-10 12:09:06 550
原创 LeetCode 319 -Bulb Switcher ( JAVA )
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off
2016-04-10 11:24:18 670
原创 LeetCode 169 -Majority Element ( JAVA )
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element
2016-04-09 12:09:37 681 1
原创 LeetCode 217 -Contains Duplicate ( JAVA )
Given 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 if every element
2016-04-09 12:00:12 689
原创 LeetCode 171 -Excel Sheet Column Number ( JAVA )
Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ...
2016-04-09 11:19:51 590
原创 LeetCode 242 -Valid Anagram ( JAVA )
Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:You may a
2016-04-09 10:06:21 552
原创 LeetCode 122 -Best Time to Buy and Sell Stock II ( JAVA )
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on
2016-04-08 21:10:28 402
原创 LeetCode 121 -Best Time to Buy and Sell Stock ( JAVA )
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),
2016-04-08 20:15:24 389
原创 LeetCode 238 -Product of Array Except Self ( JAVA )
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
2016-04-08 17:10:57 437
原创 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-04-06 19:00:41 465
原创 LeetCode 260 -Single Number III ( JAVA )
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given
2016-04-06 18:26:43 738
原创 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
2016-04-06 16:22:58 814
原创 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 you
2016-04-06 15:57:59 342
原创 LeetCode 226 -Invert Binary Tree ( JAVA )
Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1/** * Definition for a binary tree node. * public class TreeNode {
2016-04-06 09:43:58 720
原创 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./** * Definition for a bina
2016-04-05 18:27:44 978
原创 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 on
2016-04-05 17:32:15 573
原创 LeetCode 136 -Single Number ( JAVA )
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using e
2016-04-05 16:58:51 885
原创 LeetCode 292 -Nim Game ( JAVA )
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-04-05 15:56:47 429
原创 LeetCode 2 - Add Two Numbers ( JAVA )
Difficulity : 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 r
2016-04-04 16:59:37 453
利用JAVA注解与反射 - 实现SQL语句自动生成
2017-08-04
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人