var shuffle = function(nums, n) {
let res=[]
for(let i=0
res.push(nums[i])
res.push(nums[i+n])
}
return res
}
var isMatch = function(s, p) {
const m=s.length
const n=p.length
const dp=new Array(m+1).fill(0).map(()=>new Array(n+1).fill(0))
dp[0][0]=true
for(let i=1
dp[0][i]=false
}
for(let i=2
dp[0][i]=dp[0][i-2]&&p[i-1]==="*"
}
for(let i=1
dp[i][0]=false
}
const match=(i,j)=>{
if(j==='.'){
return true
}if(j!=='.'){
if(i===j){
return true
}
}
return false
}
for(let i=1
for(let j=1
if(p[j-1]!=="*"){
if(match(s[i-1],p[j-1])){
dp[i][j]=dp[i-1][j-1]
}else{
dp[i][j]=false
}
}else{
if(match(s[i-1],p[j-2])){
dp[i][j]=dp[i-1][j]|dp[i][j-2]
}else{
dp[i][j]=dp[i][j-2]
}
}
}
}
return dp[m][n]
}
var validateStackSequences = function(pushed, popped) {
let stack=[]
let j=0
for(let i=0
stack.push(pushed[i])
while(stack.length!==0 && stack[stack.length-1]===popped[j]){
stack.pop()
j++
}
}
return stack.length===0
}
var exchange = function(nums) {
let l=0,r=nums.length-1
while(l<r){
while(l<r && nums[l]%2===1){
l++
}
while(l<r && nums[r]%2===0){
r--
}
if(l<r){
let temp=nums[l]
nums[l]=nums[r]
nums[r]=temp
}
}
return nums
}
var getKthFromEnd = function(head, k) {
let node=head
let length=0
while(node){
length++
node=node.next
}
let vhead=head
for(let i=0
vhead=vhead.next
}
return vhead
}