![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
hlinghoney
IT界小小码农一个
展开
-
122. Best Time to Buy and Sell Stock II
题目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 one a原创 2016-03-01 12:37:25 · 256 阅读 · 0 评论 -
HTML5学习(二)
6.表单html5带来了新的表单元素、新输入控件类型和新的属性,新的输入控件类型包括:email:用于输入电子邮件地址;url:用于输入URL;date:用于输入日期和时间;number:用于输入数值;range:用于生成滑动条;search:用于搜索框;Data Pickers:日期选择器;tel:用于输入电话号码;color:用于选择颜色;input类型-email email原创 2016-03-10 22:53:07 · 563 阅读 · 0 评论 -
144. Binary Tree Preorder Traversal &&94. Binary Tree Inorder Traversal
题目Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive solution is trivia原创 2016-03-02 23:20:02 · 282 阅读 · 0 评论 -
58. Length of Last Word
题目Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the string. If the last word does not exist, return 0.Note: A word is define原创 2016-03-11 13:04:42 · 285 阅读 · 0 评论 -
226. Invert Binary Tree
题目Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1翻译将一个二叉树进行转换。思路递归算法: 1、交换根节点的左右子树。 2、对左右子树分别执行递归反转 。源码C++/** * Definition原创 2016-02-29 21:02:08 · 263 阅读 · 0 评论 -
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 structurally identical and the nodes have the same value.Subscribe to see原创 2016-02-29 21:46:44 · 349 阅读 · 0 评论 -
232. Implement Queue using Stacks&225. Implement Stack using Queues
题目Implement the following operations of a queue using stacks.push(x) – Push element x to the back of queue. pop() – Removes the element from in front of queue. peek() – Get the front element. empty(原创 2016-03-14 21:45:06 · 335 阅读 · 0 评论 -
字符串反转
题目:Write a function that takes a string as input and returns the string reversed.Example: Given s = “hello”, return “olleh”.源码:/** * @param {string} s * @return {string} */var reverseString = func原创 2016-04-28 16:15:09 · 483 阅读 · 0 评论 -
使用JavaScript进行进制转换将字符串转换为十进制
1.将数字转换成十进制 parseInt(res,x); 将任意进制字符串转换为十进制,x为如二进制,八进制,十六进制, 第二数数不写即为最常用的转换为整型十进制;var res=10001;parseInt(res,2);//res为二进制,将res转换成十进制进制parseInr(res,16)//res为十六进制,将res转换成十进制进制2.将字符反转 arr.split(原创 2016-05-23 16:04:13 · 5599 阅读 · 0 评论 -
华为机试--最高分是多少
老师想知道从某某同学当中,分数最高的是多少,现在请你编程模拟老师的询问。当然,老师有时候需要更新某位同学的成绩. 输入描述: 输入包括多组测试数据。 每组输入第一行是两个正整数N和M(0 < N <= 30000,0 < M < 5000),分别代表学生的数目和操作的数目。 学生ID编号从1编到N。 第二行包含N个整数,代表这N个学生的初始成绩,其中第i个数代表ID为i原创 2016-07-09 22:02:52 · 1927 阅读 · 0 评论 -
【leetcode】53. Maximum Subarray
题目Find the contiguous subarray within an array (containing at least one number) which has the largest sum.求一个数组的连续子序列的最大值。For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray原创 2016-07-03 11:41:20 · 334 阅读 · 0 评论 -
微软面试--数组去重方法
题目: 实现数组去重 输入: arr数组,即需要去重的数组 输出: 返回去重后数组的长度/* 数组去重1: 重新建立一个临时数组,遍历原数组中的元素,并判断每个元素是否在新数组中出现过。若没出现过则加入,出现过,则不加入。 时间复杂度n^2,空间复杂度n @param arr 输入需要去重的数组 @return 返回去重后数组的长度 *原创 2016-07-27 22:58:35 · 762 阅读 · 0 评论 -
328. Odd Even Linked List
题目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-03-08 22:49:42 · 390 阅读 · 0 评论 -
242. Valid Anagram
题目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.翻译给定两个字符串,写一个函数确定t是s的相同字母原创 2016-03-01 13:05:36 · 267 阅读 · 0 评论 -
171. Excel Sheet Column Number
题目Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number. A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27原创 2016-03-01 13:20:16 · 271 阅读 · 0 评论 -
319. Bulb Switcher
题目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-03-01 17:41:10 · 315 阅读 · 0 评论 -
260. Single Number III
题目iven 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 nums = [1,原创 2016-03-02 17:37:19 · 287 阅读 · 0 评论 -
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.Subscribe to see which companies asked this question翻译给定一个罗马数字,将它转换成整数。思路罗马数字的含义:I->1;V->5;原创 2016-03-03 16:19:38 · 306 阅读 · 0 评论 -
235. Lowest Common Ancestor of a Binary Search Tree
题目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 between t原创 2016-03-03 20:24:35 · 350 阅读 · 0 评论 -
206. Reverse Linked List
题目Reverse a singly linked list.click to show more hints.Subscribe to see which companies asked this question源码JavaScript/** * Definition for singly-linked list. * function ListNode(val) { * this原创 2016-03-08 10:49:01 · 332 阅读 · 0 评论 -
191. Number of 1 Bits
题目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 00000000000原创 2016-03-08 11:08:20 · 322 阅读 · 0 评论 -
获取URL参数
获取 url 中的参数 1. 指定参数名称,返回该参数的值 或者 空字符串 2. 不指定参数名称,返回全部的参数对象 或者 {} 3. 如果存在多个同名参数,则返回数组 输入例子: getUrlParam(‘http://www.nowcoder.com?key=1&key=2&key=3&test=4#hehe‘, ‘key’)输出例子: [1, 2, 3]源码:function get原创 2016-08-25 15:40:51 · 1448 阅读 · 0 评论