leetcode
shiter
CSDN博客专家,人工智能与大数据领域优秀创作者,累计近500W人次访问。 熟悉自然语言处理(NLP)、大数据(Spark 、Elasticsearch)、数据分析(Scala,Python),计算机视觉(OpenCV、立体匹配)等领域的研发工作。世界500强,高级算法工程师, 曾参与并负责国家级大数据项目,负责大健康平台相关开发与管理工作,负责金融行业AI与大数据平台产品设计、开发与落地。编程不仅仅是技术,还是艺术!talk is cheap,show me the code!
展开
-
leetcode 205 Isomorphic Strings
Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with another chara原创 2015-04-30 14:26:17 · 2697 阅读 · 2 评论 -
leetcode 27 Remove Element
Remove Element Total Accepted: 60351 Total Submissions: 187833 My Submissions Given an array and a value, remove all instances of that value in place and ret原创 2015-06-24 15:56:47 · 3214 阅读 · 0 评论 -
leetcode 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. 我的解决方案: /** * Definition for singly-linked list.原创 2015-06-05 21:59:59 · 2754 阅读 · 0 评论 -
leetcode 9 Palindrome Number 回文数
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints: Could negative integers be palindromes? (ie, -1)If you are thinking of converting the inte原创 2015-06-28 20:21:36 · 2504 阅读 · 1 评论 -
leetcode 20 Valid Parentheses 括号匹配
Given a string containing just the characters '(', ')', '{', '}', '[' and']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all val原创 2015-06-30 22:34:02 · 2623 阅读 · 1 评论 -
leetcode 67 Add Binary
Add Binary Total Accepted: 46815 Total Submissions: 189215 My Submissions Given two binary strings, return their sum (also a binary string). For example,a =原创 2015-07-05 21:49:19 · 4502 阅读 · 0 评论 -
leetcode 102 Binary Tree Level Order Traversal
// TreeToVector.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include #include #include "stdio.h"using namespace std; struct TreeNode { int val; TreeNode *left;原创 2015-07-14 22:53:54 · 2930 阅读 · 0 评论 -
leetcode 217 Contains Duplicate 数组中是否有重复的数字
Contains Duplicate Total Accepted: 26477 Total Submissions: 73478 My SubmissionsGiven an array of integers, find if the array contains any duplicates. Your function should retu原创 2015-08-09 21:48:10 · 3584 阅读 · 0 评论 -
leetcode 226 Invert Binary Tree 翻转二叉树
大牛没有能做出来的题,我们要好好做一做 Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired翻译 2015-06-23 23:53:58 · 4054 阅读 · 2 评论 -
leetcode 110 Balanced Binary Tree
Balanced Binary Tree Total Accepted: 63288 Total Submissions: 198315 My Submissions Given a binary tree, determine if it is height-balanced.For this problem, a height-bal...原创 2015-07-19 20:43:02 · 1980 阅读 · 2 评论 -
leetcode 2 Add Two Numbers
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-02-27 17:35:57 · 2110 阅读 · 2 评论 -
leetcode 5 Longest Palindromic Substring--最长回文字符串
问题描述Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 所谓回文字符串,就是一个字符串,从左原创 2016-08-29 00:22:17 · 2706 阅读 · 0 评论 -
leetcode 10 Regular Expression Matching(简单正则表达式匹配)
最近代码写的少了,而leetcode一直想做一个python,c/c++解题报告的专题,c/c++一直是我非常喜欢的,c语言编程练习的重要性体现在linux内核编程以及一些大公司算法上机的要求,python主要为了后序转型数据分析和机器学习,所以今天来做一个难度为hard 的简单正则表达式匹配。做了很多leetcode题目,我们来总结一下套路: 首先一般是检查输入参数是否正确,然后是处理算法的特殊原创 2017-02-21 01:19:33 · 7717 阅读 · 1 评论 -
leetcode 11 Container with Most Water
1.题目描述Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0).Find原创 2017-04-16 21:02:28 · 1339 阅读 · 0 评论 -
leetcode 12 ,13 Integer to Roman &&Roman to Integer 罗马与阿拉伯数组转换
12 Integer to Roman 13 Roman to Integer 有可能不注意的结果: class Solution {public:/*1、相同的数字连写,所表示的数等于这些数字相加得到的数,如:Ⅲ = 3;2、小的数字在大的数字的右边,所表示的数等于这些数字相加得到的数, 如:Ⅷ = 8;Ⅻ = 12;3、小的数字,(限于Ⅰ、X 和C)在大的数字的左边,所表示的原创 2017-11-18 00:25:53 · 833 阅读 · 5 评论 -
leetcode 14 Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. 分析】公共前缀指的是所有字符串的前缀都相同。显然,这个最长公共前缀的长度不会超过所有字符串中最短的那个。我们先求得最短串长minLen,然后遍历所有字符串中的前minLen是否相等。 我的解决...原创 2015-06-29 22:53:06 · 2978 阅读 · 0 评论 -
leetcode 新题型----SQL,shell,system design
leetcode 主要是一个针对北美的coder人群找工作的代码练习网站,我在2015年初次接触这个网站的时候,总共只有200多道题目,是一个类似acm 的a题网站。这些年变化越来越大,主要是因为找工作当然是多样化的考核过程,leetcode 也逐渐与时俱进,推出了下面几个类别的联系,今天我们随便挑几个练习一下:175. Combine Two Tables —SQLTable: Person原创 2017-08-20 23:52:37 · 1639 阅读 · 0 评论 -
leetcode Sum 系列----寻找和为定值的多个数
july 大神有个程序员编程艺术系列,第五章《寻找和为定值的多个数》,现在我们站在大牛的肩膀上,对leetcode上n个数求和的系列问题做个阶段性总结。1.leetcode No.1 2sumGiven an array of integers, return indices of the two numbers such that they add up to a specifi...原创 2018-02-17 01:10:19 · 8273 阅读 · 0 评论 -
leetcode 26 Remove Duplicates from Sorted Array
Remove Duplicates from Sorted ArrayTotal Accepted: 66627 Total Submissions: 212739 My Submissions Given a sorted array, remove the duplicates in place such that原创 2015-06-25 15:52:53 · 2551 阅读 · 0 评论 -
leetcode 88 Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 intonums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal tom + n) to hold addit原创 2015-06-24 22:47:51 · 3798 阅读 · 0 评论 -
leetcode 204题求素数个数
Description:Count the number of prime numbers less than a non-negative number, n 提示晒数法:http://en.wikipedia.org/wiki/Sieve_of_Eratostheneshttps://primes.utm.edu/howmany.html 别人的代码:原创 2015-04-28 22:20:57 · 3227 阅读 · 0 评论 -
leetcode 198 House Robber
今天看了一个华为西安研究院的一个女生代码大神的总结很有感悟,下面这句话送给大家:只有好的程序员才能写出人类可以理解的代码You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint st原创 2015-04-30 16:40:46 · 1737 阅读 · 0 评论 -
leetcode 203 Remove Linked List Elements
Remove all elements from a linked list of integers that have valueval.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5 // Linklist.cp原创 2015-04-29 15:01:55 · 2351 阅读 · 2 评论 -
leetcode 70 Climbing Stairs
Climbing Stairs You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you原创 2015-04-29 17:46:09 · 3584 阅读 · 0 评论 -
leetcode 202 Happy Number
Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares o原创 2015-04-29 17:06:19 · 3633 阅读 · 0 评论 -
leetcode 160 Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists: A: a1 → a2 ↘原创 2015-05-11 17:44:22 · 1603 阅读 · 0 评论 -
leetcode 155 Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. • push(x) – Push element x onto stack. • pop() – Removes the element on top of the stack. • top()原创 2015-05-11 23:56:31 · 2001 阅读 · 0 评论 -
leetcode 190 Reverse Bits
Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as 00111001011110原创 2015-05-04 15:46:12 · 1603 阅读 · 0 评论 -
leetcode 172 Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.解决思路: 决定阶乘末尾零的个数其实是数列中5出现的次数,比如5的阶乘一个零。1024的阶乘末尾到底有几个零呢?http://bbs.csdn.net/原创 2015-05-04 23:49:15 · 1535 阅读 · 0 评论 -
leetcode 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,6,7,1,2,3,4]. Note: Try to come up as many solutions as you can, th原创 2015-05-04 20:28:49 · 1531 阅读 · 0 评论 -
leetcode 19 Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, the linked li原创 2015-05-05 22:31:55 · 1495 阅读 · 0 评论 -
leetcode 7 Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers.Have you thought about this? Here are some good questions to ask before coding. Bonu原创 2015-05-13 21:41:17 · 1431 阅读 · 0 评论 -
leetcode 104 Maximum Depth of Binary Tree二叉树求深度
Maximum Depth of Binary Tree Total Accepted: 63668 Total Submissions: 141121 My Submissions Question Solution Given a binary tree, find its maximum depth.The maximum depth is the number of nodes原创 2015-05-13 22:16:12 · 5237 阅读 · 0 评论 -
leetcode 169 Majority Element 冰山查询
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 always原创 2015-05-06 15:40:01 · 2023 阅读 · 0 评论 -
leetcode 83 Remove Duplicates from Sorted List
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. 下面是我的解决方案,考虑测试用例: 1,1 1原创 2015-05-20 22:41:06 · 1910 阅读 · 0 评论 -
leetcode 165 Compare Version Numbers
Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0.You may assume that the version strings are non-empty and cont原创 2015-05-08 11:28:34 · 1557 阅读 · 0 评论 -
leetcode 8 String to Integer (atoi)
String to Integer (atoi)Total Accepted:52232 Total Submissions:401038 My Submissions Question Solution Implement atoi to convert a string to an integer.Hint: Carefully conside原创 2015-06-24 00:03:23 · 2200 阅读 · 0 评论 -
leetcode 37. Sudoku Solver 36. Valid Sudoku 数独问题
三星机试也考了类似的题目,只不过是要针对给出的数独修改其中三个错误数字,总过10个测试用例只过了3个与世界500强无缘了36. Valid SudokuDetermine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled...原创 2016-05-04 22:07:52 · 2142 阅读 · 0 评论