leetCode Oj
潜水的陈大喵
Build a knowledge structure only belongs to me. I'm an INTJ girl.
展开
-
leetCode Q1:Two Num(java)
1、题目链接:https://leetcode.com/problems/two-sum/description/2、题目内容(楼主直接用中文描述了):给一个一维数组,一个目标值target,要求返回数组里其中两个数的和为target的对应的下标值。例如: Given nums = [2, 7, 11, 15], target = 9,Because nums[0] + ...原创 2017-10-21 21:15:42 · 323 阅读 · 0 评论 -
27. Remove Element(运行效率打败了99.96%的人)
我的解决办法效率很高,因为采取了倒序遍历给定val的方法。题目:Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must...原创 2018-09-29 14:47:50 · 160 阅读 · 0 评论 -
26. Remove Duplicates from Sorted Array
题目:Given a sorted array nums, remove the duplicates in-place such thateach element appear only once and return the new length.Do not allocate extra space for another array, you must do this by mo...原创 2018-09-26 19:33:54 · 97 阅读 · 0 评论 -
53. Maximum Subarray
题目:Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explana...原创 2018-10-03 02:03:53 · 141 阅读 · 0 评论 -
38. Count and Say
题目:The count-and-say sequence is the sequence of integers with the first five terms as following:1. 12. 113. 214. 12115. 1112211 is read off as "one 1" or 11.11 is read off...原创 2018-10-02 22:44:57 · 96 阅读 · 0 评论 -
21. Merge Two Sorted Lists
题目:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output...原创 2018-09-26 16:34:06 · 105 阅读 · 0 评论 -
35. Search Insert Position(二分查找加插入下标)
题目: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 arra...原创 2018-10-02 16:59:52 · 167 阅读 · 0 评论 -
20. Valid Parentheses
题目:Given a string containing just the characters '(', ')', '{', '}', '[' and ']',determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type ...原创 2018-09-26 00:28:51 · 93 阅读 · 0 评论 -
14. Longest Common Prefix
题目:Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".Example 1:Input: ["flower","flow","flight"]Outp...原创 2018-09-24 22:25:51 · 95 阅读 · 0 评论 -
13. (LeetCode-java)Roman to Integer
题目:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D ...原创 2018-09-24 19:39:37 · 103 阅读 · 0 评论 -
32位整数溢出处理-LeetCodeQ7:整数逆序
问题如下:给一个32位的整数,求它的逆序整数。Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21注意:这个问题假设限定整数不超过32位。如果逆序后的结果超过32位,则返回0.(如:1534236469的逆序为:9646324351。这个溢出了。)解答原创 2018-01-18 13:26:03 · 2385 阅读 · 0 评论 -
leetCode Q3:Longest Substring Without Repeating Characters(java)
1、题目链接:https://leetcode.com/problems/longest-substring-without-repeating-characters/description/2、题目内容(中文版):给一个字符串,要求返回最长的不含重复字符的子字符串的长度。例如:"abcabcbb",答案是"abc",返回3"bbbbb",答案是"b", 返回1."pww原创 2017-10-23 17:01:30 · 208 阅读 · 0 评论 -
leetCode Q2:Add Two Numbers(java)
1、题目链接:https://leetcode.com/problems/add-two-numbers/description/2、题目内容(楼主直接用中文描述了):给两个非空链表代表两个非负整数,非负整数逆序地存储在对应的链表中(比如13存储成3->1),链表的每个节点包含一个一位的整数。要求:将两个整数相加,结果存储在一个同样格式的链表中并返回。例如:Input: (2原创 2017-10-22 16:31:31 · 174 阅读 · 0 评论 -
28. Implement strStr()
题目:Implement strStr().Return the index of the first occurrence of needle in haystack,or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output: 2Example...原创 2018-09-30 00:30:42 · 100 阅读 · 0 评论