Given a list, rotate the list to the right by k places, where k is non-negative.For example:
Given 1->2->3->4->5->NULL and k = 2,
return 4->5->1->2->3->NULL. 巨沒勁的一道題,當k>length 時,我以為origin
題目: LEETCODE。 Given a singly linked list?L:?L0→L1→…→Ln-1→Ln,reorder it to:?L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For example, Given?{1,2,3,4}, reorder it to?{1,4,2
題目描述:(鏈接) Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. 解題思路: 上代碼 1 class Solution { 2 public: 3 vector<
題目 Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical and the nodes have the same value. 解法一 思路 先序遍歷的遞歸 代碼 /*** Definition for a binary
class Solution(object):def fib(self, N):""":type N: int:rtype: int"""F=[0]*31F[1]=1for i in range(2,31):F[i]=F[i-1]+F[i-2]return F[N] ? 轉載于:https://www.cnblogs.com/zywscq/p/10562609.html
題目 Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. You may not modify the values in the lis
題目 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 value in the nodes. You should try to do it in place. The program should run in O(1) space complexi
題目 Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3]. The lar