mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-24 10:33:34 +08:00
Translate all code to English (#1836)
* Review the EN heading format. * Fix pythontutor headings. * Fix pythontutor headings. * bug fixes * Fix headings in **/summary.md * Revisit the CN-to-EN translation for Python code using Claude-4.5 * Revisit the CN-to-EN translation for Java code using Claude-4.5 * Revisit the CN-to-EN translation for Cpp code using Claude-4.5. * Fix the dictionary. * Fix cpp code translation for the multipart strings. * Translate Go code to English. * Update workflows to test EN code. * Add EN translation for C. * Add EN translation for CSharp. * Add EN translation for Swift. * Trigger the CI check. * Revert. * Update en/hash_map.md * Add the EN version of Dart code. * Add the EN version of Kotlin code. * Add missing code files. * Add the EN version of JavaScript code. * Add the EN version of TypeScript code. * Fix the workflows. * Add the EN version of Ruby code. * Add the EN version of Rust code. * Update the CI check for the English version code. * Update Python CI check. * Fix cmakelists for en/C code. * Fix Ruby comments
This commit is contained in:
@@ -13,21 +13,21 @@ from modules import ListNode, list_to_linked_list
|
||||
|
||||
def linear_search_array(nums: list[int], target: int) -> int:
|
||||
"""Linear search (array)"""
|
||||
# Traverse array
|
||||
# Traverse the array
|
||||
for i in range(len(nums)):
|
||||
if nums[i] == target: # Found the target element, thus return its index
|
||||
if nums[i] == target: # Found the target element, return its index
|
||||
return i
|
||||
return -1 # Did not find the target element, thus return -1
|
||||
return -1 # Target element not found, return -1
|
||||
|
||||
|
||||
def linear_search_linkedlist(head: ListNode, target: int) -> ListNode | None:
|
||||
"""Linear search (linked list)"""
|
||||
# Traverse the list
|
||||
# Traverse the linked list
|
||||
while head:
|
||||
if head.val == target: # Found the target node, return it
|
||||
return head
|
||||
head = head.next
|
||||
return None # Did not find the target node, thus return None
|
||||
return None # Target node not found, return None
|
||||
|
||||
|
||||
"""Driver Code"""
|
||||
@@ -42,4 +42,4 @@ if __name__ == "__main__":
|
||||
# Perform linear search in linked list
|
||||
head: ListNode = list_to_linked_list(nums)
|
||||
node: ListNode | None = linear_search_linkedlist(head, target)
|
||||
print("Target node value 3's corresponding node object is", node)
|
||||
print("The corresponding node object for target node value 3 is", node)
|
||||
|
||||
Reference in New Issue
Block a user