随笔分类 - LeetCode__算法algorithm
逻辑思维--算法设计与分析
摘要:Total Accepted: 19397 Total Submissions: 67937 Difficulty: Easy You are playing the following Bulls and Cows game with your friend: You write down a n
阅读全文
摘要:Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?/** * Definition for singly-linked l...
阅读全文
摘要:Given a sorted integer array without duplicates, return the summary of its ranges.For example, given[0,1,2,4,5,7], return["0->2","4->5","7"].Credits:S...
阅读全文
摘要:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100), return ...
阅读全文
摘要:1.方法一:n&(n-1)=0/** * @param {number} n * @return {boolean} */var isPowerOfTwo = function(n) { if((n>0) && (!(n&(n-1)))){ return true; } ...
阅读全文
摘要:Given an array of strings, group anagrams together.For example, given:["eat", "tea", "tan", "ate", "nat", "bat"],Return:[ ["ate", "eat","tea"], ["na...
阅读全文
摘要:Given two stringssandt, write a function to determine iftis an anagram ofs.For example,s= "anagram",t= "nagaram", return true.s= "rat",t= "car", retur...
阅读全文
摘要:Ugly NumberⅡWrite a program to find then-th ugly number.Ugly numbers are positive numbers whose prime factors only include2, 3, 5. For example,1, 2, 3...
阅读全文
摘要:Implement Queue using Stacksclass MyQueue { Stack s1 = new Stack(); Stack s2 = new Stack(); // Push element x to the back of queue. ...
阅读全文
摘要:/** * Definition for singly-linked list. * function ListNode(val) { * this.val = val; * this.next = null; * } *//** * @param {ListNode} head *...
阅读全文
摘要:JavaScript/** * @param {string} pattern * @param {string} str * @return {boolean} */var wordPattern = function(pattern, str) { var strArray = str.s...
阅读全文
摘要:JavaScript/*** @param {number} n* @return {boolean}*/var canWinNim = function(n) {if(n % 4 == 0){return false;}else{return true;}};拓游戏:n个石子,一次最多拿m个棋子;...
阅读全文

浙公网安备 33010602011771号