This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //kotlin | |
| class Lnode constructor(var data: Any){ | |
| //尾节点指向尾节点自身 | |
| var next: Lnode = this | |
| //尾部插入 | |
| fun tInsert(data: Any){ | |
| val point: Lnode = Lnode(data) | |
| var temp: Lnode = this | |
| while (temp.next != temp) | |
| temp = temp.next |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.ArrayList; | |
| import java.util.List; | |
| public class Test { | |
| private long bigOdd; | |
| public long getBigOdd() { | |
| return bigOdd; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 1. Two Sum | |
| * Given an array of integers, return indices of the two numbers such that they add up to a specific target. | |
| * You may assume that each input would have exactly one solution, and you may not use the same element twice. | |
| */ | |
| class Solution { | |
| public int[] twoSum(int[] nums, int target) { | |
| int[] sum = new int[2]; | |
| breakFor: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 2.Add Two Numbers | |
| * You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. | |
| * You may assume the two numbers do not contain any leading zero, except the number 0 itself. | |
| * | |
| * Definition for singly-linked list. | |
| * public class ListNode { | |
| * int val; | |
| * ListNode next; | |
| * ListNode(int x) { val = x; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.HashMap; | |
| import java.util.Map; | |
| /** | |
| * 3. Longest Substring Without Repeating Characters | |
| * Given a string, find the length of the longest substring without repeating characters. | |
| */ | |
| // Time Limit Exceeded... | |
| class Solution { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution { | |
| public String longestPalindrome(String s) { | |
| String ans; | |
| if (!s.isEmpty()) { | |
| char[] chars = s.toCharArray(); | |
| int length = chars.length; | |
| int longest = 1; | |
| ans = String.valueOf(chars[0]); | |
| for (int i = 1; i < length; i++) { | |
| int len = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution { | |
| public String convert(String s, int numRows) { | |
| String ans; | |
| if (!s.isEmpty() && numRows > 0) { | |
| if (numRows == 1) { | |
| return s; | |
| } | |
| int length = s.length(); | |
| char[] chars = new char[length]; | |
| int lIndex; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 7. Reverse Integer | |
| * Reverse digits of an integer. | |
| */ | |
| class Solution { | |
| public int reverse(int x) { | |
| // 0x80000000 = ~0x80000000 + 1 | |
| if (x == Integer.MIN_VALUE) { | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.HashMap; | |
| import java.util.Map; | |
| /** | |
| * 9. Palindrome Number | |
| * Determine whether an integer is a palindrome. Do this without extra space. | |
| */ | |
| class Solution { | |
| public boolean isPalindrome(int x) { | |
| if (x < 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.ArrayList; | |
| import java.util.HashMap; | |
| import java.util.List; | |
| import java.util.Map; | |
| /** | |
| * 10. Regular Expression Matching | |
| * Implement regular expression matching with support for '.' and '*'. | |
| */ | |
| class Solution { |
OlderNewer