The API: int read4(char *buf) reads 4 characters at a time from a file. The return value is the actual number …
标签:LeetCode
LeetCode[7] - First Bad Version
这个挺直接的,也被李特标了EASY. 就是在1~n里面找第一个出错点。其实就是搜一个数字i(同时用isBadVersion(i))检查这个数字是否报错。那搜index的活,直接binary search就好了。 注意特别…
024 Swap Nodes in Pairs[M]
1 题目描述 Given a linked list, swap every two adjacent nodes and return its head. Your algorithm should use only …
49. Group Anagrams python
49. Group Anagrams python 题目: https://leetcode.com/problems/anagrams/ 难度 : Medium 我又来使用我的取巧神奇python大法 “c…
[LintCode][System Design] Toy Factory
Problem More LeetCode Discussions Factory is a design pattern in common usage. Please implement a ToyFactory w…
[LeetCode]709. To Lower Case
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. 将字…
[剑指offer] 用两个栈实现队列
本文首发于我的个人博客:尾尾部落 题目描述 用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。 解题思路 两个栈 stack1 和 stack2: push 动作都在 stack1 中进…
445. Add Two Numbers II
Medium You are given two non-empty linked lists representing two non-negative integers. The most significant d…
Inorder Successor in Binary Search Tree
Given a binary search tree and a node in it, find the in-order successor of that node in the BST. If the given…
Leetcode - Longest Palindrome
My code: public class Solution { public int longestPalindrome(String s) { if (s == null || s.length() == 0) { …
LeetCode刷题之Maximum Subarray
Problem Find the contiguous subarray within an array (containing at least one number) which has the largest su…
leetcode 20. 有用的括号
给定一个只包含 ‘(‘,’)’,'{‘,’}’,'[‘,’]’ 的字符串,推断字符串是不是有用。 有…