• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






struggleforit

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理
上一页 1 2 3 4 5 下一页

2017年11月10日

ArrayAndString(数组和字符串)
摘要: 1.实现一个算法,确定一个字符串的所有字符是否全都不同。假使不允许使用额外的数据结构,又该怎么处理? public class UniqueChars { public static void main(String[] args) { // TODO Auto-generated method s 阅读全文
posted @ 2017-11-10 17:11 struggleforit 阅读(377) 评论(0) 推荐(0)
 

2017年6月2日

Chapter nine Dynamic Programming(动态规划)
摘要: 1.triangle(数字三角形) 给定一个数字三角形,找到从顶部到底部的最小路径和。每一步可以移动到下面一行的相邻数字上。如果你只用额外空间复杂度O(n)的条件下完成可以获得加分,其中n是数字三角形的总行数。 自顶向下的解法: public class Solution { /** * @para 阅读全文
posted @ 2017-06-02 17:15 struggleforit 阅读(312) 评论(0) 推荐(0)
 
Chapter eight Data Structure(数据结构)
摘要: 数据结构:可以认为是一个集合,并且提供集合上的若干操作。 队列 Queue支持操作:O(1) Push / O(1) Pop / O(1) Top BFS的主要数据结构,多联系BFS的相关题目即可 栈 Stack支持操作:O(1) Push / O(1) Pop / O(1) Top 非递归实现DF 阅读全文
posted @ 2017-06-02 16:04 struggleforit 阅读(294) 评论(0) 推荐(0)
 

2017年5月25日

Chapter seven Two Pointers(两根指针)
摘要: 1.move-zeroes(移动零) 给一个数组 nums 写一个函数将 0 移动到数组的最后面,非零元素保持原数组的顺序。必须在原数组上操作,同时最小化操作数。 public class Solution { /** * @param nums an integer array * @return 阅读全文
posted @ 2017-05-25 15:38 struggleforit 阅读(343) 评论(0) 推荐(0)
 

2017年5月21日

Chapter six Linked List & Array(链表与数组)
摘要: 链表: 1.reverse-nodes-in-k-group(k组翻转链表)【hard】 给你一个链表以及一个k,将这个链表从头指针开始每k个翻转一下。链表元素个数不是k的倍数,最后剩余的不用翻转。 /** * Definition for singly-linked list. * public 阅读全文
posted @ 2017-05-21 23:21 struggleforit 阅读(320) 评论(0) 推荐(0)
 

2017年5月19日

Chapter five Depth First Search(深度优先搜索)
摘要: 组合搜索问题 Combination 问题模型:求出所有满足条件的“组合”。判断条件:组合中的元素是顺序无关的。时间复杂度:与 2^n 相关。 1.Chapter one 第2题 subsets(子集) 2.Chapter one 第3题 subsets-ii(子集II) 3.combination 阅读全文
posted @ 2017-05-19 17:12 struggleforit 阅读(284) 评论(0) 推荐(0)
 

2017年5月11日

Chapter four Breadth First Search(宽度优先搜索)
摘要: BFS最主要的数据结构是Queue,由LinkedList实现。 二叉树上的BFS: 1.binary-tree-level-order-traversal(二叉树的层次遍历) 给出一棵二叉树,返回其节点值的层次遍历(逐层从左往右访问) BFS解法一【基本模板】: public class Solu 阅读全文
posted @ 2017-05-11 23:32 struggleforit 阅读(306) 评论(0) 推荐(0)
 

2017年5月3日

Chapter three Binary Tree & Divide Conquer(二叉树&分治)
摘要: 1.binary-tree-preorder-traversal(二叉树的前序遍历)根-左-右 给出一棵二叉树,返回其节点值的前序遍历。 非递归解法【要记住】: /** * Definition of TreeNode: * public class TreeNode { * public int 阅读全文
posted @ 2017-05-03 11:33 struggleforit 阅读(250) 评论(0) 推荐(0)
 

2017年4月24日

Chapter two Binary Search(二分法)
摘要: 1.classical-binary-search(经典二分查找问题)【二分查找模板】 在一个排序数组中找一个数,返回该数出现的任意位置,如果不存在,返回-1 public class Solution { /** * @param nums: An integer array sorted in 阅读全文
posted @ 2017-04-24 13:47 struggleforit 阅读(330) 评论(0) 推荐(0)
 
Chapter one
摘要: 1.strstr(字符串查找) 对于一个给定的 source 字符串和一个 target 字符串,你应该在 source 字符串中找出 target 字符串出现的第一个位置(从0开始)。如果不存在,则返回 -1 class Solution { /** * Returns a index to th 阅读全文
posted @ 2017-04-24 13:06 struggleforit 阅读(208) 评论(0) 推荐(0)
 
上一页 1 2 3 4 5 下一页