自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Jason's BLOG

记录、收集、积累、总结、进步

  • 博客(21)
  • 收藏
  • 关注

原创 [Leetcode] Range Sum Query - Immutable

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRan

2016-11-28 14:28:37 400

原创 [Leetcode] 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 ↘

2016-11-28 11:29:52 401

原创 [Leetcode] Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.题意:查找字符串数组中的最长子串思路:1. 找到最短长度的字符串,然后求得其他字符串与最小串的最大公共长度char* longestCommonPrefix(char**strs, int strsSize) {

2016-11-23 19:10:57 332

原创 [Leetcode] Contains Duplicate II

Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j]and the difference between i and j is at most k.题

2016-11-23 16:16:55 307

原创 [Leetcode] 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

2016-11-23 13:18:26 247

原创 [Leetcode] Remove Duplicates from Sorted Array

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with

2016-11-22 13:03:47 264

原创 判断单链表是否有环

1、对于单链表而言,只有通过从头到尾的遍历方式,如果发现尾指针指向头指针则说明有环。2、使用双指针,一个遍历的速度快,一个较慢,如果快的指针追上了慢的那个说明有环:/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next;

2016-11-21 17:22:52 337

原创 [Leetcode] Remove Element

Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memory.

2016-11-21 16:41:36 259

原创 [Leetcode] Number of 1 Bits & Counting 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 000000

2016-11-19 15:27:46 351

原创 [Leetcode] 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. 前提是整个链表是有序的2.

2016-11-19 14:58:09 279

原创 [Leetcode] Best Time to Buy and Sell Stock

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-11-18 10:20:09 311

原创 [Leetcode] Power of Three

Given an integer, write a function to determine if it is a power of three.判断一个数是否为3的幂:一,除数法,最容易想到的方法:1. 首先是能够整除2. 整除到最后的数一定为1则说明TRUE否则FALSEbool isPowerOfThree(int n) { if (n <= 0)

2016-11-17 19:25:22 335

原创 [Leetcode]Contains Duplicate

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-11-17 18:53:16 281

原创 [Leetcode]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.从题目看来,得到要求:1. 长度

2016-11-17 13:31:32 367

原创 [Leetcode]Reverse Linked List-再写单链表反转

Leetcode碰巧又出现这个问题,看来面试算法这个是很常见的题型,不过很久没写过,这次写来又花了不少时间,主要耽搁在思想的选择上:一是想通过遍历时直接将指针反转,这样比较高效,但是需要处理好前后指针及后续的关系;二是通过构建一个新的链表头,然后遍历时直接将链表元素加入到新链接中,该算法比较简明;/** * Definition for singly-linked list.

2016-11-17 10:12:00 2015

原创 [Leetcode] Move Zeroes

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 fu

2016-11-16 16:42:49 280

原创 [Leetcode] Invert Binary Tree

Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1最先想到的当然是递归的思想,将两个左右指针进行互换:/** * Definition for a binary tree node.

2016-11-11 11:00:19 218

原创 [Leetcode]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

2016-11-10 16:21:52 271

原创 [Leetcode]Single Number

Given an array of integers, every element appears twice except for one. Find that single one.思路:1. 使用HASH表存储每个数组元素出现的次数2. 理解按位异或操作的本质原理int singleNumber(int* nums, int numsSize) { int

2016-11-10 14:06:24 212

原创 [Leetcode]Maximum Depth of Binary Tree

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.解:考虑深度优先访问方式求深度./** * Def

2016-11-10 13:59:50 225

原创 Jquery UI 获取选中的tab Index

在页面加载中需要对tab进行初始化,同时要注册了active属性的处理函数: $( function() { $( "#tabs" ).tabs({ activate: function( event, ui ){ refresh_ifr_page(); } }); } );function getSelectedTabIndex(){ va

2016-11-09 09:06:45 4158

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除