Skip to content

Instantly share code, notes, and snippets.

View Cee's full-sized avatar
πŸŽ€
ハネだ (<ゝω·)β˜†

Tianyu Wang Cee

πŸŽ€
ハネだ (<ゝω·)β˜†
View GitHub Profile
public class Solution {
public int[][] generateMatrix(int n) {
int[][] ret = new int[n][n];
int i = 0;
int j = 0;
for (i = 0; i < n; i++){
for (j = 0; j < n; j++){
ret[i][j] = 0;
}
}
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
/**
* Definition for binary tree
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
public class Solution {
public class Solution {
public int reverse(int x) {
if (x == 0) return x;
int digit = 0;
if (x < 0){
digit = 1;
x = -x;
}
int ret = 0;
while (x > 0){
public class Solution {
public void merge(int A[], int m, int B[], int n) {
int i = 0;
int j = 0;
while ((i < m) && (j < n)){
if (B[j] <= A[i]){
for (int k = m - 1; k >= i; k--)
A[k + 1] = A[k];
A[i] = B[j];
m++;
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
public class Solution {
public ArrayList<Integer> spiralOrder(int[][] matrix) {
ArrayList<Integer> ret = new ArrayList<Integer>();
int m = matrix.length;
if (m == 0) return ret;
int n = matrix[0].length;
int i = 0;
int j = 0;
int count = 0;
int way = 1; // 1 right 2 down 3 left 4 right
public class Solution {
public int divide(int dividend, int divisor) {
long a = dividend;
long b = divisor;
if (a == 0) return 0;
boolean flag = (a > 0) ^ (b > 0);
if (a < 0) a = -a;
if (b < 0) b = -b;
if (a < b) return 0;
long ret = 0;
/**
* Definition for singly-linked list.
* class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
/**
* Definition for singly-linked list.
* class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }