This file contains 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 List<List<Integer>> permute(int[] nums) { | |
List<List<Integer>> result = new ArrayList<>(); | |
if(nums == null || nums.length == 0) return result; | |
List<Integer> listNums = new ArrayList<>(nums.length); | |
for (int i : nums) { listNums.add(i); } | |
permute(listNums, 0, nums.length, result); |
This file contains 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 int[] searchRange(int[] nums, int target) { | |
int[] result = new int[]{-1,-1}; | |
if(nums.length == 0 || nums[0] > target) return result; | |
int start = 0, end = nums.length-1, midPoint = 0; | |
boolean found = false; | |
while(start<=end && !found){ | |
midPoint = Math.round((start + end) / 2); |
This file contains 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
public class LongestPalindrome { | |
public String longestPalindrome(String s) { | |
int length = s.length() - 1; | |
if(length <= 0) return s; | |
char[] input = s.toCharArray(); |
This file contains 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
/** | |
* Definition for singly-linked list. | |
* public class ListNode { | |
* int val; | |
* ListNode next; | |
* ListNode(int x) { val = x; } | |
* } | |
*/ | |
class Solution { | |
public ListNode addTwoNumbers(ListNode l1, ListNode l2) { |