03 2016 档案
摘要:1. python读取文件时的路径,明明是放在一个文件夹里,怎么不完整路径会错 2. file.write(str1+str2)用+拼接,不能用, 3. open()用法: 4. 在用r+模式读写文件时,写之前要file.seek(文件位置),不然无法写。
阅读全文
摘要:Given an integer, write a function to determine if it is a power of three.
阅读全文
摘要:Given an integer, write a function to determine if it is a power of two. 负数和0都不是power of 2.
阅读全文
摘要:random.sample(sequence, k),从指定序列中随机获取指定长度的片断。sample函数不会修改原有序列 numpy.nonzero() Return the indices of the elements that are non-zero.
阅读全文
摘要:Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For exa
阅读全文
摘要:You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl
阅读全文
摘要: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,
阅读全文
摘要: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
阅读全文
摘要:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. 编译错误。。。不愿debug,之后继续
阅读全文
摘要:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.
阅读全文
摘要:Reverse a singly linked list. 之前错误: 把p->next=head; 写成 ln->next=head; ln是返回链表的头指针
阅读全文
摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. You may assume that the
阅读全文
摘要: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 arr
阅读全文
摘要:Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A的ascii: 65
阅读全文
摘要: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 =
阅读全文
摘要: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 a
阅读全文
摘要:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solu
阅读全文
摘要:Invert a binary tree. class Solution { public: TreeNode* invertTree(TreeNode* root) { TreeNode* temp; if(root) { temp=root->left; root->left=root->rig
阅读全文
摘要:Given a binary tree, find its maximum depth. class Solution { public: int maxDepth(TreeNode* root) { int depth=0; if(!root) return depth; int a=maxDep
阅读全文

浙公网安备 33010602011771号