Hi @swapnil22 , I had the same case failing. Not sure if the terminating condition is correct.
D
dhananjay6
@dhananjay6
0
Reputation
8
Posts
102
Profile views
0
Followers
0
Following
Posts made by dhananjay6

RE: DFS + DP Failing Testcase

easy to understand binary search solution O(logN).
def searchRange(self, A, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ l, r, m = 0, len(A), 0 s, e = 0, 0 while l < r: m = l + (r  l) // 2 if A[m] == target: s, e = m, m while e < r1 and A[e] == A[e + 1]: # right limit e += 1 while s > l and A[s] == A[s  1]: # left limit s = 1 return [s,e] if A[m] > target: r = m else: l = m + 1 return [1, 1]

RE: [IMPORTANT NOTICE] Cheating Announcement
I guess simplest way to hack is multiple logins to same account and solving different questions and making a submissions. This will reduce the time for each submission. This can be detected by checking IP for submission. Another way is to login to same machine but working in a team with each member of working on different questions. This cannot be caught by checking IP but can be detected by time difference between submissions or time taken to finish all problems.

RE: Simple Python
@realisking Thanks for this simple solution, I reduced the code a bit more
if nums<2: return False ans,sqrt=0,int(math.sqrt(nums)) ans=sum(i+nums//i for i in range(1,sqrt+1) if not nums % i) return 2*numsans==0

RE: Basic Java solution
Nice Solution, easy to understand. Failed as TLE when I tried to implement on Python.

Simple O(n) python solution (68ms)
def isPalindrome(self, s): """ :type s: str :rtype: bool """ left=0 right=len(s)1 s=s.lower() while left<right: if not s[left].isalnum(): left+=1 elif not s[right].isalnum(): right=1 elif s[left]==s[right]: left+=1 right=1 else: return False return True

My simple Python solution  5 lines
def uniquePaths(self, m, n): path=[[1]*n]*m for i in range(1,m): for j in range(1,n): path[i][j]=path[i1][j]+path[i][j1] return(path[1][1])

My one liner python solution.
def strStr(self, haystack, needle): return haystack.find(needle)