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
/** | |
* | |
* @param {string} str | |
* @returns {string} | |
*/ | |
function longestPalindrome(str) { | |
if (!str?.length) { | |
return ""; | |
} |
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
function reverse(nums) { | |
if (!nums) return; | |
let newList = []; | |
for (let i = nums.length -1; i >= 0; i--) { | |
newList.push(nums[i]); | |
} | |
return newList; | |
} |
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
function isAnagram(s, t) { | |
let ss =s.split('').sort(); | |
let tt = t.split('').sort(); | |
if (s.length != t.length) return false; | |
for (let i = 0; i < s.length; i++) { | |
if (ss[i] != tt[i]) { | |
return false; | |
} | |
} | |
return true; |
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 Solution { | |
public void MoveZeroes(int[] nums) { | |
int indexSwap = 0; | |
for (int i = 0; i < nums.Length; i++) | |
{ | |
if (nums[i] != 0) | |
{ | |
if (i != indexSwap) | |
{ | |
nums[indexSwap] = nums[i]; |
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 Solution { | |
public int[] TwoSum(int[] nums, int target) { | |
for (int i = 0; i < nums.Length; i++) { | |
for (int j = i + 1; j < nums.Length; j++) { | |
if (nums[j] == target - nums[i]) { | |
return new int[] { i, j }; | |
} | |
} | |
} | |
return new int[0]; |
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
function removeDuplicates(nums: number[]): number[] { | |
if (nums.length === 0) return []; | |
let i=0; | |
nums.sort(); | |
for (let j =1; j < nums.length; j++) { | |
if (nums[j] != nums[i]) { | |
i++; | |
nums[i] = nums[j]; | |
} | |
} |
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
function rotate(matrix: number[][]) { | |
let n = matrix.length; | |
// transpose matrix | |
for (let i = 0; i < n; i++) { | |
for (let j = i; j < n; j++) { | |
let tmp = matrix[j][i]; | |
matrix[j][i] = matrix[i][j]; | |
matrix[i][j] = tmp; | |
console.log(tmp,matrix[j][i]); | |
} |
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
async function asyncForEach(array, callback) { | |
for (let index = 0; index < array.length; index++) { | |
await callback(array[index], index, array); | |
} | |
} |
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
package main | |
import ( | |
"github.com/gitchander/permutation" | |
"encoding/hex" | |
"crypto/sha1" | |
"crypto/hmac" | |
"strings" | |
"fmt" | |
"os" |
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
import binascii | |
import hashlib | |
import hmac | |
def genSigninRequestOtpSignature(signinType, deviceId, timestamp): | |
""" | |
url: "https://mobile-api-gateway.truemoney.com/mobile-api-gateway/api/v1/login/otp/" | |
headers: | |
username => str (ex: "09XXXXXXXX") | |
password => str (ex: "da39a3ee5e6b4b0d3255bfef95601890afd80709") |